Skip to content
Browse files

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
  • Loading branch information...
1 parent b0189f3 commit d15550aeccd5c10d7c734c523116e3da9f4b13e8 @dhh dhh committed Mar 20, 2006
Showing with 9 additions and 2 deletions.
  1. +9 −2 activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
View
11 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 @@ def update(other_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 @@ def dup
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

0 comments on commit d15550a

Please sign in to comment.
Something went wrong with that request. Please try again.