Class: Hash
Instance Method Summary collapse
- #stringify_keys ⇒ Object
- #stringify_keys! ⇒ Object
- #symbolize_and_underscore_keys ⇒ Object
- #symbolize_and_underscore_keys! ⇒ Object
- #symbolize_keys ⇒ Object
- #symbolize_keys! ⇒ Object
Instance Method Details
#stringify_keys ⇒ Object
45 46 47 48 49 50 |
# File 'lib/monkey.rb', line 45 def stringify_keys inject({}) do |, (key, value)| [key.to_s] = value end end |
#stringify_keys! ⇒ Object
54 55 56 |
# File 'lib/monkey.rb', line 54 def stringify_keys! self.replace(self.stringify_keys) end |
#symbolize_and_underscore_keys ⇒ Object
75 76 77 78 79 80 |
# File 'lib/monkey.rb', line 75 def symbolize_and_underscore_keys inject({}) do |, (key, value)| [(key.to_s.underscore.to_sym rescue key) || key] = value end end |
#symbolize_and_underscore_keys! ⇒ Object
84 85 86 |
# File 'lib/monkey.rb', line 84 def symbolize_and_underscore_keys! self.replace(self.symbolize_and_underscore_keys) end |
#symbolize_keys ⇒ Object
60 61 62 63 64 65 |
# File 'lib/monkey.rb', line 60 def symbolize_keys inject({}) do |, (key, value)| [(key.to_sym rescue key) || key] = value end end |
#symbolize_keys! ⇒ Object
69 70 71 |
# File 'lib/monkey.rb', line 69 def symbolize_keys! self.replace(self.symbolize_keys) end |