aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-03-20 03:39:46 +0000
committerRick Olson <technoweenie@gmail.com>2006-03-20 03:39:46 +0000
commitafde9943eaec9c7370c2638316128e236222df82 (patch)
tree4f642babd111a23e4b2574e722cf9f69d07099b8
parent4e7c6f58fb14ad8783062303191eebed7699965b (diff)
downloadrails-afde9943eaec9c7370c2638316128e236222df82.tar.gz
rails-afde9943eaec9c7370c2638316128e236222df82.tar.bz2
rails-afde9943eaec9c7370c2638316128e236222df82.zip
fix indifferent hash. The lambdas were acting funny in a running rails app. closes #2176
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3987 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activesupport/lib/active_support/core_ext/hash/indifferent_access.rb20
1 files changed, 15 insertions, 5 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 c84c37f87b..4b35893e20 100644
--- a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
+++ b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
@@ -8,12 +8,22 @@ class HashWithIndifferentAccess < Hash
super(constructor)
end
end
-
- convert_key_and_hashes_and_call_super = lambda { |key, *args| super(convert_key(key), *args.map{|arg| convert_value(arg) }) }
- convert_other_hash_and_call_super = lambda { |other_hash| super(convert_hash(other_hash)) }
- %w( [] []= fetch store delete has_key? include? key? member? ).each{ |method_name| define_method method_name, &convert_key_and_hashes_and_call_super }
- %w( == eql? replace initialize_copy merge merge! update ).each{ |method_name| define_method method_name, &convert_other_hash_and_call_super }
+ %w( [] []= fetch store delete has_key? include? key? member? ).each do |method_name|
+ class_eval %(
+ def #{method_name}(key, *args)
+ super(convert_key(key), *args.map { |arg| convert_value(arg) })
+ end
+ )
+ end
+ #define_method method_name, &convert_key_and_hashes_and_call_super }
+ %w( == eql? replace initialize_copy merge merge! update ).each do |method_name|
+ class_eval %(
+ def #{method_name}(other_hash)
+ super(convert_hash(other_hash))
+ end
+ )
+ end
def invert
self.class.new.replace(super)