Module: HashReplaceKey
- Included in:
- Hash
- Defined in:
- lib/core_ext/hash_replace_key.rb
Instance Method Summary collapse
Instance Method Details
#replace_key(original, replacement) ⇒ Object
2 3 4 |
# File 'lib/core_ext/hash_replace_key.rb', line 2 def replace_key(original, replacement) dup.replace_key!(original, replacement) end |
#replace_key!(original, replacement) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/core_ext/hash_replace_key.rb', line 6 def replace_key!(original, replacement) return self unless has_key?(original) self[replacement] = delete(original) self end |