aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorDavid Lee <davidomundo@gmail.com>2011-05-17 03:01:31 -0700
committerDavid Lee <davidomundo@gmail.com>2011-05-17 03:01:31 -0700
commit94617d7da1e76daeae3a05c61b42321163f93d62 (patch)
tree7da2c0aab714b2a04489ff13bb3755a0a8f20931 /activesupport/lib
parentb0385fe1b2a147d982eadbeb716dd1c7598a93e0 (diff)
downloadrails-94617d7da1e76daeae3a05c61b42321163f93d62.tar.gz
rails-94617d7da1e76daeae3a05c61b42321163f93d62.tar.bz2
rails-94617d7da1e76daeae3a05c61b42321163f93d62.zip
Optimize parts of HashWithIndifferentAccess
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/hash_with_indifferent_access.rb12
1 files changed, 10 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 8ec4f6e09a..39ebc1ec82 100644
--- a/activesupport/lib/active_support/hash_with_indifferent_access.rb
+++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb
@@ -10,6 +10,10 @@ module ActiveSupport
true
end
+ def with_indifferent_access
+ self
+ end
+
def initialize(constructor = {})
if constructor.is_a?(Hash)
super()
@@ -58,8 +62,12 @@ module ActiveSupport
# hash_1.update(hash_2) # => {"key"=>"New Value!"}
#
def update(other_hash)
- other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) }
- self
+ if other_hash.is_a? HashWithIndifferentAccess
+ super(other_hash)
+ else
+ other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) }
+ self
+ end
end
alias_method :merge!, :update