Module: HashSymbolizeKeys
- Included in:
- Hash
- Defined in:
- lib/hash_symbolize_keys.rb
Instance Method Summary collapse
Instance Method Details
#recursive_symbolize_keys! ⇒ Object
23 24 25 26 27 |
# File 'lib/hash_symbolize_keys.rb', line 23 def recursive_symbolize_keys! underscore_and_symbolize_keys! values.select { |v| v.is_a?(Hash) }.each { |h| h.recursive_symbolize_keys! } self end |
#underscore_and_symbolize_keys! ⇒ Object
16 17 18 19 20 21 |
# File 'lib/hash_symbolize_keys.rb', line 16 def underscore_and_symbolize_keys! keys.each do |key| self[(key.to_s.underscore.to_sym rescue key)] = delete(key) if key.respond_to?(:to_sym) && !key.is_a?(Fixnum) end self end |