aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2009-09-13 21:11:33 +0200
committerXavier Noria <fxn@hashref.com>2009-09-13 21:11:33 +0200
commita079f60b634d43f5c85c4d589aa3fbaf6b1cdd86 (patch)
treec354636bda051ea77ffb0ef7df5eaade2b996e88 /activesupport
parent119040fafbbc48ae0dec867663edab3d744fc8e6 (diff)
downloadrails-a079f60b634d43f5c85c4d589aa3fbaf6b1cdd86.tar.gz
rails-a079f60b634d43f5c85c4d589aa3fbaf6b1cdd86.tar.bz2
rails-a079f60b634d43f5c85c4d589aa3fbaf6b1cdd86.zip
details that symbolize_keys symbolizes keys as long as they respond to to_sym (so "all" may not be really all)
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/keys.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/keys.rb b/activesupport/lib/active_support/core_ext/hash/keys.rb
index ffaa69570f..ecd63293b4 100644
--- a/activesupport/lib/active_support/core_ext/hash/keys.rb
+++ b/activesupport/lib/active_support/core_ext/hash/keys.rb
@@ -15,7 +15,8 @@ class Hash
self
end
- # Return a new hash with all keys converted to symbols.
+ # Return a new hash with all keys converted to symbols, as long as
+ # they respond to +to_sym+.
def symbolize_keys
inject({}) do |options, (key, value)|
options[(key.to_sym rescue key) || key] = value
@@ -23,7 +24,8 @@ class Hash
end
end
- # Destructively convert all keys to symbols.
+ # Destructively convert all keys to symbols, as long as they respond
+ # to +to_sym+.
def symbolize_keys!
self.replace(self.symbolize_keys)
end