Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/hash.rb
Instance Method Summary collapse
- #billyfy_keys! ⇒ Object
-
#rubyify_keys! ⇒ Object
Converts all of the keys to strings, optionally formatting key name.
- #success? ⇒ Boolean
Instance Method Details
#billyfy_keys! ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hash.rb', line 17 def billyfy_keys! keys.each{|k| v = delete(k) new_key = k.to_s.camelize(:lower) self[new_key] = v v.rubyify_keys! if v.is_a?(Hash) v.each{|p| p.billyfy_keys! if p.is_a?(Hash)} if v.is_a?(Array) } self end |
#rubyify_keys! ⇒ Object
Converts all of the keys to strings, optionally formatting key name
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/hash.rb', line 6 def rubyify_keys! keys.each{|k| v = delete(k) new_key = k.to_s.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 |
#success? ⇒ Boolean
28 29 30 |
# File 'lib/hash.rb', line 28 def success? self["success"] end |