This project is archived and is in readonly mode.
[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
-
Repository June 25th, 2010 @ 11:05 PM
- State changed from new to committed
(from [158e22dae006b7e630cdb20e6e37cf93fd8d1c56]) Alias ActiveSupport::OrderedHash#update to ActiveSupport::OrderedHash.merge!
This ensures that an OrderedHash's keys are set up appropriately when using update.
[#4973 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/158e22dae006b7e630cdb20e6e37cf... -
Repository June 25th, 2010 @ 11:21 PM
(from [05defcd63a8c60e30eaf040e73e7a4a8e95659ea]) Alias ActiveSupport::OrderedHash#update to ActiveSupport::OrderedHash.merge!
This ensures that an OrderedHash's keys are set up appropriately when using update.
[#4973 state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/05defcd63a8c60e30eaf040e73e7a4...
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
Referenced by
- 4973 [PATCH] ActiveSupport::OrderedHash#update Does Not Set Keys [#4973 state:committed]
- 4973 [PATCH] ActiveSupport::OrderedHash#update Does Not Set Keys [#4973 state:committed]