From a079f60b634d43f5c85c4d589aa3fbaf6b1cdd86 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 13 Sep 2009 21:11:33 +0200 Subject: details that symbolize_keys symbolizes keys as long as they respond to to_sym (so "all" may not be really all) --- activesupport/lib/active_support/core_ext/hash/keys.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activesupport') 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 -- cgit v1.2.3