Class: Hash
Instance Method Summary collapse
- #recursively_symbolize_keys! ⇒ Object
- #symbolize_keys ⇒ Object
-
#symbolize_keys! ⇒ Object
Destructively convert all keys to symbols.
Instance Method Details
#recursively_symbolize_keys! ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ubiquitously/extensions/core.rb', line 29 def recursively_symbolize_keys! self.symbolize_keys! self.values.each do |v| if v.is_a? Hash v.recursively_symbolize_keys! elsif v.is_a? Array v.recursively_symbolize_keys! end end self end |
#symbolize_keys ⇒ Object
41 42 43 44 45 46 |
# File 'lib/ubiquitously/extensions/core.rb', line 41 def symbolize_keys inject({}) do |, (key, value)| [(key.to_sym rescue key) || key] = value end end |
#symbolize_keys! ⇒ Object
Destructively convert all keys to symbols.
49 50 51 |
# File 'lib/ubiquitously/extensions/core.rb', line 49 def symbolize_keys! self.replace(self.symbolize_keys) end |