Hi all,
On versions of Ruby prior to 1.9, using update on an ActiveSupport::OrderedHash will not set the keys correctly. This means that it is not possible to iterate over the hash using each or get the array of keys.
For example:
hash = ActiveSupport::OrderedHash.new hash.update(:name => "Bob") # => #<OrderedHash {:name=>"Bob"}> hash.keys # => hash.each do |key, value| puts value end # =>
This can be resolved by simply aliasing update to merge! as per Rubinius' implementation (c.f. http://github.com/evanphx/rubinius/blob/master/kernel/common/hash.rb#L447 ).
I have posted a patch including tests at https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4973-patch-activesupportorderedhashupdate-does-not-set-keys and would appreciate any feedback whatsoever.