This project is archived and is in readonly mode.

#4973 ✓committed
Paul Mucur

[PATCH] ActiveSupport::OrderedHash#update Does Not Set Keys

Reported by Paul Mucur | June 25th, 2010 @ 08:28 PM

Using update on an ActiveSupport::OrderedHash does not set keys correctly meaning that it cannot be iterated over with each, etc.

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 fixed by aliasing update to merge! as is done in Rubinius' Hash implementation (c.f. http://github.com/evanphx/rubinius/blob/master/kernel/common/hash.r... ).

Please find attached a patch and test case to resolve this issue.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments