Skip to content
Browse files

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>
  • Loading branch information...
1 parent f8f3653 commit 05defcd63a8c60e30eaf040e73e7a4a8e95659ea @mudge mudge committed with jeremy Jun 25, 2010
Showing with 8 additions and 0 deletions.
  1. +2 −0 activesupport/lib/active_support/ordered_hash.rb
  2. +6 −0 activesupport/test/ordered_hash_test.rb
View
2 activesupport/lib/active_support/ordered_hash.rb
@@ -134,6 +134,8 @@ def merge!(other_hash)
self
end
+ alias_method :update, :merge!
+
def merge(other_hash)
dup.merge!(other_hash)
end
View
6 activesupport/test/ordered_hash_test.rb
@@ -222,4 +222,10 @@ def test_order_after_yaml_serialization_with_nested_arrays
assert_equal @ordered_hash.keys, @deserialized_ordered_hash.keys
assert_equal @ordered_hash.values, @deserialized_ordered_hash.values
end
+
+ def test_update_sets_keys
+ @updated_ordered_hash = ActiveSupport::OrderedHash.new
+ @updated_ordered_hash.update(:name => "Bob")
+ assert_equal [:name], @updated_ordered_hash.keys
+ end
end

0 comments on commit 05defcd

Please sign in to comment.
Something went wrong with that request. Please try again.