diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-01-23 05:38:02 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-01-23 05:38:02 +0000 |
commit | 9c24899ab0fad8baa4db543dd45f3d20ae95d3b3 (patch) | |
tree | 16becf9099b0ecfcd238986f8d0fbb3b6d0fa7ea /activesupport/lib/active_support | |
parent | 010e999092c04bd5ef9185db284a8733bc1b6ee6 (diff) | |
download | rails-9c24899ab0fad8baa4db543dd45f3d20ae95d3b3.tar.gz rails-9c24899ab0fad8baa4db543dd45f3d20ae95d3b3.tar.bz2 rails-9c24899ab0fad8baa4db543dd45f3d20ae95d3b3.zip |
Fix merge and dup for hashes with indifferent access (closes #3404) [kenneth.miller@bitfield.net]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3468 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/hash/indifferent_access.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb index 458f8961a3..c96e63b169 100644 --- a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +++ b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb @@ -41,6 +41,14 @@ class HashWithIndifferentAccess < Hash indices.collect {|key| self[convert_key(key)]} end + def dup + HashWithIndifferentAccess.new(self) + end + + def merge(hash) + self.dup.update(hash) + end + protected def convert_key(key) key.kind_of?(Symbol) ? key.to_s : key |