Module: Payments::HashExt
- Included in:
- Hash
- Defined in:
- lib/payments_pl/hash_ext.rb
Instance Method Summary collapse
- #stringify_keys ⇒ Object
- #stringify_keys! ⇒ Object
- #symbolize_keys ⇒ Object
- #symbolize_keys! ⇒ Object
Instance Method Details
#stringify_keys ⇒ Object
3 4 5 6 7 8 |
# File 'lib/payments_pl/hash_ext.rb', line 3 def stringify_keys inject({}) do |, (key, value)| [key.to_s] = value end end |
#stringify_keys! ⇒ Object
10 11 12 13 14 15 |
# File 'lib/payments_pl/hash_ext.rb', line 10 def stringify_keys! keys.each do |key| self[key.to_s] = delete(key) end self end |
#symbolize_keys ⇒ Object
17 18 19 20 21 22 |
# File 'lib/payments_pl/hash_ext.rb', line 17 def symbolize_keys inject({}) do |, (key, value)| [(key.to_sym rescue key) || key] = value end end |
#symbolize_keys! ⇒ Object
24 25 26 |
# File 'lib/payments_pl/hash_ext.rb', line 24 def symbolize_keys! self.replace(self.symbolize_keys) end |