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.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.