aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-03-20 18:53:52 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-03-20 18:53:52 +0000
commitd15550aeccd5c10d7c734c523116e3da9f4b13e8 (patch)
tree474d38be366868e098c52c66bd927cdee21316be /activesupport
parentb0189f3f2ffd9de95ba2332cdcfaf48d28081e18 (diff)
downloadrails-d15550aeccd5c10d7c734c523116e3da9f4b13e8.tar.gz
rails-d15550aeccd5c10d7c734c523116e3da9f4b13e8.tar.bz2
rails-d15550aeccd5c10d7c734c523116e3da9f4b13e8.zip
Fixed the hash.delete :sym (closes #2176) [Stefan Kaes]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4005 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/indifferent_access.rb11
1 files changed, 9 insertions, 2 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 80012aa17d..d60b605942 100644
--- a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
+++ b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
@@ -1,4 +1,6 @@
-# This implementation is HODEL-HASH-9600 compliant
+# this class has dubious semantics and we only have it so that
+# people can write params[:key] instead of params['key']
+
class HashWithIndifferentAccess < Hash
def initialize(constructor = {})
if constructor.is_a?(Hash)
@@ -24,6 +26,7 @@ class HashWithIndifferentAccess < Hash
other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) }
self
end
+
alias_method :merge!, :update
def key?(key)
@@ -49,7 +52,11 @@ class HashWithIndifferentAccess < Hash
def merge(hash)
self.dup.update(hash)
end
-
+
+ def delete(key)
+ super(convert_key(key))
+ end
+
protected
def convert_key(key)
key.kind_of?(Symbol) ? key.to_s : key