diff options
author | laserlemon <steve.richert@gmail.com> | 2010-10-11 21:21:40 -0400 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-11-07 10:19:51 -0200 |
commit | 02039e9752bcb214c2ad85859ecf47dcbb892225 (patch) | |
tree | 4a796747c8a7d6f637d2c53b5847c63404076995 /activesupport/lib/active_support | |
parent | 6709078eb1f61a1f8d54fcd82e9a07e96383ec8a (diff) | |
download | rails-02039e9752bcb214c2ad85859ecf47dcbb892225.tar.gz rails-02039e9752bcb214c2ad85859ecf47dcbb892225.tar.bz2 rails-02039e9752bcb214c2ad85859ecf47dcbb892225.zip |
Ensure that HashWithIndifferentAccess duplication preserves class (for sublclasses) and default value [#5724 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/hash_with_indifferent_access.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index c406dd3c2e..06dd18966e 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -28,7 +28,7 @@ module ActiveSupport end def self.new_from_hash_copying_default(hash) - ActiveSupport::HashWithIndifferentAccess.new(hash).tap do |new_hash| + new(hash).tap do |new_hash| new_hash.default = hash.default end end @@ -97,7 +97,9 @@ module ActiveSupport # Returns an exact copy of the hash. def dup - HashWithIndifferentAccess.new(self) + self.class.new(self).tap do |new_hash| + new_hash.default = default + end end # Merges the instantized and the specified hashes together, giving precedence to the values from the second hash |