Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/rubyify_keys.rb
Instance Method Summary collapse
-
#rubyify_keys! ⇒ Object
Converts all of the keys to strings, optionally formatting key name.
Instance Method Details
#rubyify_keys! ⇒ Object
Converts all of the keys to strings, optionally formatting key name
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/rubyify_keys.rb', line 4 def rubyify_keys! keys.each{|k| v = delete(k) new_key = k.to_s.to_underscore! self[new_key] = v v.rubyify_keys! if v.is_a?(Hash) v.each{|p| p.rubyify_keys! if p.is_a?(Hash)} if v.is_a?(Array) } self end |