diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-08 03:44:27 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-08 03:44:27 -0700 |
commit | c2b55c4fbfc427e9ca468fce0392de591c87747a (patch) | |
tree | 40d6cb605293f78791633ce7a5b8a5279fc4ac41 /activesupport/lib/active_support/core_ext | |
parent | e5a01224195b289748b3996e6deb0587baf625d8 (diff) | |
parent | 099eb2b3fd9526e06c30b9878780f31091e011aa (diff) | |
download | rails-c2b55c4fbfc427e9ca468fce0392de591c87747a.tar.gz rails-c2b55c4fbfc427e9ca468fce0392de591c87747a.tar.bz2 rails-c2b55c4fbfc427e9ca468fce0392de591c87747a.zip |
Merge pull request #454 from dlee/nested_indifferent_access
indifferent access should recurse Hash subclasses
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r-- | activesupport/lib/active_support/core_ext/hash/indifferent_access.rb | 12 |
1 files changed, 12 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 aad4b61e16..c2a6476604 100644 --- a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +++ b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb @@ -9,4 +9,16 @@ class Hash def with_indifferent_access ActiveSupport::HashWithIndifferentAccess.new_from_hash_copying_default(self) end + + # Called when object is nested under an object that receives + # #with_indifferent_access. This method with be called on the current object + # by the enclosing object and is aliased to #with_indifferent_access by + # default. Subclasses of Hash may overwrite this method to return +self+ if + # converting to an +ActiveSupport::HashWithIndifferentAccess+ would not be + # desirable. + # + # b = {:b => 1} + # {:a => b}.with_indifferent_access["a"] # calls b.nested_under_indifferent_access + # + alias nested_under_indifferent_access with_indifferent_access end |