Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/conductor/hash.rb
Overview
Hash helpers
Instance Method Summary collapse
-
#symbolize_keys ⇒ Hash
Convert all keys in hash to symbols.
-
#symbolize_keys! ⇒ Hash
Destructive version of #symbolize_keys.
Instance Method Details
#symbolize_keys ⇒ Hash
Convert all keys in hash to symbols. Works on nested hashes
23 24 25 |
# File 'lib/conductor/hash.rb', line 23 def symbolize_keys each_with_object({}) { |(k, v), hsh| hsh[k.to_sym] = (v.is_a?(Hash) || v.is_a?(Array)) ? v.symbolize_keys : v } end |
#symbolize_keys! ⇒ Hash
Destructive version of #symbolize_keys
12 13 14 |
# File 'lib/conductor/hash.rb', line 12 def symbolize_keys! replace symbolize_keys end |