Class: Hash
Instance Method Summary collapse
Instance Method Details
#recursively(&block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/tworgy/recursively.rb', line 18 def recursively(&block) inject({}) do |hash, (key, value)| if value.is_a?(Hash) hash[key] = value.recursively(&block) else hash[key] = value end yield hash end end |
#recursively!(&block) ⇒ Object
29 30 31 |
# File 'lib/tworgy/recursively.rb', line 29 def recursively!(&block) replace(recursively(&block)) end |