diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-06-13 20:40:11 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-06-13 20:40:11 +0000 |
commit | 2e6f6ced428f3b3b574e7f6a7e1511b2cf470039 (patch) | |
tree | eff2f72f5dfc77ac4318aac75013f1aff3ef418a /activesupport/lib/active_support/core_ext | |
parent | 37a370d8d4e3e1a5bf707ffac9cd188c07572248 (diff) | |
download | rails-2e6f6ced428f3b3b574e7f6a7e1511b2cf470039.tar.gz rails-2e6f6ced428f3b3b574e7f6a7e1511b2cf470039.tar.bz2 rails-2e6f6ced428f3b3b574e7f6a7e1511b2cf470039.zip |
r1300@iwill: jeremy | 2005-06-13 18:31:29 -0700
Ticket 1436 - Faster indifferent hash
r1301@iwill: jeremy | 2005-06-13 18:45:28 -0700
Apply, tweak, test.
r1305@iwill: jeremy | 2005-06-13 18:50:24 -0700
Updated changelog.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1413 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-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) |