aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-10-16 18:56:13 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-10-16 18:56:13 +0000
commitcfffedb4d86bcf3190da5e6433b694fc2e9f1bd9 (patch)
treecb3fea4f87f93a3e7430a7da92eb071036e66a09 /activesupport/lib/active_support
parenta2172e75f589f038ed10806e9a32be99d4d69f89 (diff)
downloadrails-cfffedb4d86bcf3190da5e6433b694fc2e9f1bd9.tar.gz
rails-cfffedb4d86bcf3190da5e6433b694fc2e9f1bd9.tar.bz2
rails-cfffedb4d86bcf3190da5e6433b694fc2e9f1bd9.zip
Hash#symbolize_keys behaves well with integer keys. Closes #9890.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7945 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/keys.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/keys.rb b/activesupport/lib/active_support/core_ext/hash/keys.rb
index a9169cf4a5..4d32a6b8a5 100644
--- a/activesupport/lib/active_support/core_ext/hash/keys.rb
+++ b/activesupport/lib/active_support/core_ext/hash/keys.rb
@@ -24,7 +24,7 @@ module ActiveSupport #:nodoc:
# Return a new hash with all keys converted to symbols.
def symbolize_keys
inject({}) do |options, (key, value)|
- options[key.to_sym] = value
+ options[key.to_sym || key] = value
options
end
end
@@ -32,8 +32,8 @@ module ActiveSupport #:nodoc:
# Destructively convert all keys to symbols.
def symbolize_keys!
keys.each do |key|
- unless key.is_a?(Symbol)
- self[key.to_sym] = self[key]
+ unless key.is_a?(Symbol) || (new_key = key.to_sym).nil?
+ self[new_key] = self[key]
delete(key)
end
end