Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/core_ext/hash_patch.rb
Instance Method Summary collapse
Instance Method Details
#symbolize_keys ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/core_ext/hash_patch.rb', line 2 def symbolize_keys inject({ }) do |, (key, value)| new_key = case key when String Integer(key) rescue key.to_sym end new_value = case value when Hash then value.symbolize_keys when String Integer(value) rescue value else value end [new_key] = new_value end end |
#symbolize_keys! ⇒ Object
21 22 23 |
# File 'lib/core_ext/hash_patch.rb', line 21 def symbolize_keys! self.replace(self.symbolize_keys) end |