Permalink
Browse files

details that symbolize_keys symbolizes keys as long as they respond t…

…o to_sym (so "all" may not be really all)
  • Loading branch information...
1 parent 119040f commit a079f60b634d43f5c85c4d589aa3fbaf6b1cdd86 @fxn fxn committed Sep 13, 2009
Showing with 4 additions and 2 deletions.
  1. +4 −2 activesupport/lib/active_support/core_ext/hash/keys.rb
@@ -15,15 +15,17 @@ def stringify_keys!
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
options
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

0 comments on commit a079f60

Please sign in to comment.