Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#4973

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.

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

State: committed
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Repository
    Repository
    • 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 [PATCH] ActiveSupport::OrderedHash#update Does Not Set Keys state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/158e22dae006b7e630cdb20e6e37cf...

    June 25th, 2010 @ 11:05 PM

  2. Repository
    Repository

    (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 [PATCH] ActiveSupport::OrderedHash#update Does Not Set Keys state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/05defcd63a8c60e30eaf040e73e7a4...

    June 25th, 2010 @ 11:21 PM