What's the "Rubyist" way to do the following data structure transformation:
I have
incoming = [ {:date => 20090501, :width => 2}, {:date => 20090501, :height => 7}, {:date => 20090501, :depth => 3}, {:date => 20090502, :width => 4}, {:date => 20090502, :height => 6}, {:date => 20090502, :depth => 2}, ]
and I want to collapse these by :date, to end up with
outgoing = [ {:date => 20090501, :width => 2, :height => 7, :depth => 3}, {:date => 20090502, :width => 4, :height => 6, :depth => 2}, ]
An array of arrays would also be fine at the last step, provided that the columns are in the same order in each row. Also, importantly, I do not know all the hash keys in advance (that is, I do not know :width, :height, or :depth -- they could be :cats, :dogs, and :hamsters).