Merge array of hashes, keeping duplicate values as arrays
I think the refactor is barely readable, the first version is better. Anyway, if you use functional abstractions, instead of doing a imperative processing from scratch, algorithms tend to be more clear. 

In this case, we can use the abstraction Enumerable#map_by (a group_by variation where you can control both the grouping function and the accumulated values) and write:

require 'facets'

class Array
  def merge_hashes
    flat_map(&amp;:to_a).map_by { |k, v| [k, v] }
  end 
end


Note that this snippet always returns an array as a value, instead of the scalar/list you have.