Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/heisenberg/hashext.rb
Instance Method Summary collapse
Instance Method Details
#recursive_symbolize_keys ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/heisenberg/hashext.rb', line 2 def recursive_symbolize_keys new_hash = self.dup new_hash.symbolize_keys! new_hash.values.select{ |v| v.is_a?(Hash) }.each &:recursive_symbolize_keys! new_hash.values.select{ |v| v.is_a?(Array) }.each { |h| h.each &:recursive_symbolize_keys! } new_hash end |
#recursive_symbolize_keys! ⇒ Object
10 11 12 13 |
# File 'lib/heisenberg/hashext.rb', line 10 def recursive_symbolize_keys! symbolize_keys! values.select{ |v| v.is_a?(Hash) }.each { |h| h.recursive_symbolize_keys! } end |