diff options
author | David Graham <dgraham@github.com> | 2012-10-16 13:05:25 -0600 |
---|---|---|
committer | David Graham <dgraham@github.com> | 2012-10-26 11:36:35 -0600 |
commit | f38e752bdf27668faf1125479f815832484c0a72 (patch) | |
tree | ece0c6c0c6959edcba2e8fed61aea84dc8a7b60c /activesupport/lib | |
parent | 6ac33f9e4b4dbfe34f9884d7b262a7ba2c3356e1 (diff) | |
download | rails-f38e752bdf27668faf1125479f815832484c0a72.tar.gz rails-f38e752bdf27668faf1125479f815832484c0a72.tar.bz2 rails-f38e752bdf27668faf1125479f815832484c0a72.zip |
Implement replace method so key? works correctly.
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/hash_with_indifferent_access.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index 0c78f1611f..306d80b2df 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -204,6 +204,14 @@ module ActiveSupport replace(reverse_merge( other_hash )) end + # Replaces the contents of this hash with other_hash. + # + # h = { "a" => 100, "b" => 200 } + # h.replace({ "c" => 300, "d" => 400 }) #=> {"c"=>300, "d"=>400} + def replace(other_hash) + super(self.class.new_from_hash_copying_default(other_hash)) + end + # Removes the specified key from the hash. def delete(key) super(convert_key(key)) |