Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/hydra/hash.rb
Instance Method Summary collapse
-
#stringify_keys ⇒ Object
Stringify the keys in the hash.
-
#stringify_keys! ⇒ Object
Stringify the keys in the hash in place.
Instance Method Details
#stringify_keys ⇒ Object
Stringify the keys in the hash. Returns a new hash.
3 4 5 6 7 8 |
# File 'lib/hydra/hash.rb', line 3 def stringify_keys inject({}) do |, (key, value)| [key.to_s] = value end end |
#stringify_keys! ⇒ Object
Stringify the keys in the hash in place.
10 11 12 13 14 15 |
# File 'lib/hydra/hash.rb', line 10 def stringify_keys! keys.each do |key| self[key.to_s] = delete(key) end self end |