diff options
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/hash/indifferent_access.rb | 14 |
1 files changed, 4 insertions, 10 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 91445610e2..92653171f9 100644 --- a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +++ b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb @@ -8,16 +8,10 @@ class HashWithIndifferentAccess < Hash super(constructor) end end - - alias_method :regular_reader, :[] unless method_defined?(:regular_reader) - - def [](key) - case key - when Symbol: regular_reader(key.to_s) || regular_reader(key) - when String: regular_reader(key) || regular_reader(key.to_sym) - else regular_reader(key) - end - end + + def default(key) + self[key.to_s] if key.is_a?(Symbol) + end alias_method :regular_writer, :[]= unless method_defined?(:regular_writer) |