Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/rubytter/core_ext.rb
Instance Method Summary collapse
- #stringify_keys ⇒ Object
- #stringify_keys! ⇒ Object
- #symbolize_keys ⇒ Object
- #symbolize_keys! ⇒ Object
Instance Method Details
#stringify_keys ⇒ Object
2 3 4 5 6 7 |
# File 'lib/rubytter/core_ext.rb', line 2 def stringify_keys inject({}) do |, (key, value)| [key.to_s] = value end end |
#stringify_keys! ⇒ Object
9 10 11 12 13 14 |
# File 'lib/rubytter/core_ext.rb', line 9 def stringify_keys! keys.each do |key| self[key.to_s] = delete(key) end self end |
#symbolize_keys ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rubytter/core_ext.rb', line 16 def symbolize_keys inject({}) do |, (key, value)| [(key.to_sym rescue key) || key] = value end end |
#symbolize_keys! ⇒ Object
23 24 25 |
# File 'lib/rubytter/core_ext.rb', line 23 def symbolize_keys! self.replace(self.symbolize_keys) end |