From aa57e66fec3a131f5d246b8950a2c3286f858b78 Mon Sep 17 00:00:00 2001 From: Bradford Folkens Date: Thu, 12 Mar 2009 15:03:01 +0000 Subject: Ensure HWIA#reverse_merge! retrurns HWIA [#421 state:resolved] Signed-off-by: Pratik Naik --- .../lib/active_support/core_ext/hash/indifferent_access.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activesupport/lib') 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 c96c5160b3..34ba8a005d 100644 --- a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +++ b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb @@ -91,6 +91,12 @@ class HashWithIndifferentAccess < Hash self.dup.update(hash) end + # Performs the opposite of merge, with the keys and values from the first hash taking precedence over the second. + # This overloaded definition prevents returning a regular hash, if reverse_merge is called on a HashWithDifferentAccess. + def reverse_merge(other_hash) + super other_hash.with_indifferent_access + end + # Removes a specified key from the hash. def delete(key) super(convert_key(key)) -- cgit v1.2.3