Module: HashHelper::DeepInvert
- Included in:
- Hash
- Defined in:
- lib/hash_helper/deep_invert.rb
Instance Method Summary collapse
-
#deep_invert ⇒ Hash
Deeply inverts a hash, creating a new structure where the values in the original hash are moved outward, and the keys are reversed in the nesting.
Instance Method Details
#deep_invert ⇒ Hash
Deeply inverts a hash, creating a new structure where the values in the original hash are moved outward, and the keys are reversed in the nesting.
13 14 15 16 17 |
# File 'lib/hash_helper/deep_invert.rb', line 13 def deep_invert each_with_object({}) do |(outer_key, outer_value), result| traverse_and_invert(outer_value, [outer_key], result) end end |