From 9c24899ab0fad8baa4db543dd45f3d20ae95d3b3 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 23 Jan 2006 05:38:02 +0000 Subject: 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 --- .../lib/active_support/core_ext/hash/indifferent_access.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activesupport/lib/active_support/core_ext') 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 -- cgit v1.2.3