Method: Hash#deep_rekey!
- Defined in:
- lib/core/facets/hash/deep_rekey.rb
#deep_rekey!(key_map = nil, &block) ⇒ Object
Synonym for Hash#deep_rekey, but modifies the receiver in place (and returns it).
foo = { :person=>{ :name=>'Gavin', :wife=>:Lisa } }
foo.deep_rekey!{ |k| k.to_s } #=> { "person"=>{ "name"=>"Gavin", "wife"=>:Lisa } }
foo #=> { "person"=>{ "name"=>"Gavin", "wife"=>:Lisa } }
CREDIT: Trans, Gavin Kistner, Ryan Duryea
51 52 53 |
# File 'lib/core/facets/hash/deep_rekey.rb', line 51 def deep_rekey!(key_map=nil, &block) replace(deep_rekey(key_map, &block)) end |