aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-12-16 23:48:24 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-12-16 23:48:24 +0000
commit05a5209f823f18e423e320f6bce4a91532c8bd03 (patch)
tree18b50ddd859036456f8c6ef8d4168d8bfd5f9f10 /activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
parent0fc805697564b4b730b37ea9d1400dcbaad8e323 (diff)
downloadrails-05a5209f823f18e423e320f6bce4a91532c8bd03.tar.gz
rails-05a5209f823f18e423e320f6bce4a91532c8bd03.tar.bz2
rails-05a5209f823f18e423e320f6bce4a91532c8bd03.zip
HashWithIndifferentAccess#to_hash converts to a Hash with String keys and the same default value. Fix Hash#reverse_update to be an alias for reverse_merge./script/console More thoroughly test the reverse_* methods.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5725 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext/hash/indifferent_access.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/indifferent_access.rb7
1 files changed, 6 insertions, 1 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 9a3b02e5d5..6c7e6d76ac 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,4 @@
-# this class has dubious semantics and we only have it so that
+# This class has dubious semantics and we only have it so that
# people can write params[:key] instead of params['key']
class HashWithIndifferentAccess < Hash
@@ -64,6 +64,11 @@ class HashWithIndifferentAccess < Hash
def stringify_keys!; self end
def symbolize_keys!; self end
+ # Convert to a Hash with String keys.
+ def to_hash
+ Hash.new(default).merge(self)
+ end
+
protected
def convert_key(key)
key.kind_of?(Symbol) ? key.to_s : key