aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorPaul Mucur <mudge@mudge.name>2010-06-25 15:35:11 +0100
committerJeremy Kemper <jeremy@bitsweat.net>2010-06-25 15:02:20 -0700
commit158e22dae006b7e630cdb20e6e37cf93fd8d1c56 (patch)
tree969fddd6fbb038c569e2c449b6860473f4c9f649 /activesupport
parent5e2b473b478d93d6a1aa627d688b2b2ce05fa9ef (diff)
downloadrails-158e22dae006b7e630cdb20e6e37cf93fd8d1c56.tar.gz
rails-158e22dae006b7e630cdb20e6e37cf93fd8d1c56.tar.bz2
rails-158e22dae006b7e630cdb20e6e37cf93fd8d1c56.zip
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>
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/ordered_hash.rb2
-rw-r--r--activesupport/test/ordered_hash_test.rb6
2 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb
index 91de722748..a19d6c3532 100644
--- a/activesupport/lib/active_support/ordered_hash.rb
+++ b/activesupport/lib/active_support/ordered_hash.rb
@@ -149,6 +149,8 @@ module ActiveSupport
self
end
+ alias_method :update, :merge!
+
def merge(other_hash, &block)
dup.merge!(other_hash, &block)
end
diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb
index 0f36f5204d..dca5c5d0c0 100644
--- a/activesupport/test/ordered_hash_test.rb
+++ b/activesupport/test/ordered_hash_test.rb
@@ -244,4 +244,10 @@ class OrderedHashTest < Test::Unit::TestCase
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