Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 158e22dae006b7e630cdb20e6e37cf93fd8d1c56 1 parent 5e2b473
Paul Mucur mudge authored jeremy committed
2  activesupport/lib/active_support/ordered_hash.rb
View
@@ -149,6 +149,8 @@ def merge!(other_hash)
self
end
+ alias_method :update, :merge!
+
def merge(other_hash, &block)
dup.merge!(other_hash, &block)
end
6 activesupport/test/ordered_hash_test.rb
View
@@ -244,4 +244,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
Please sign in to comment.
Something went wrong with that request. Please try again.