Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/snibbets/hash.rb
Instance Method Summary collapse
-
#stringify_keys ⇒ Object
Turn all keys into string.
-
#symbolize_keys ⇒ Object
Turn all keys into symbols.
Instance Method Details
#stringify_keys ⇒ Object
Turn all keys into string
Return a copy of the hash where all its keys are strings
8 9 10 |
# File 'lib/snibbets/hash.rb', line 8 def stringify_keys each_with_object({}) { |(k, v), hsh| hsh[k.to_s] = v.is_a?(Hash) ? v.stringify_keys : v } end |
#symbolize_keys ⇒ Object
Turn all keys into symbols
13 14 15 |
# File 'lib/snibbets/hash.rb', line 13 def symbolize_keys each_with_object({}) { |(k, v), hsh| hsh[k.to_sym] = v.is_a?(Hash) ? v.symbolize_keys : v } end |