Module: YamlNormalizer::Ext::Nested
- Defined in:
- lib/yaml_normalizer/ext/nested.rb
Overview
YamlNormalizer::Ext::Nested extends instances of Hash to provide the additional public helper method nested. The approach of extending Hash instances avoids monkey-patching a Ruby Core class and using refinements.
Instance Method Summary collapse
-
#nested ⇒ Hash
Transforms a flat key-value pair Hash into a tree-shaped Hash, assuming tree levels are separated by a dot.
Instance Method Details
#nested ⇒ Hash
Transforms a flat key-value pair Hash into a tree-shaped Hash, assuming tree levels are separated by a dot. nested does not modify the instance of Hash it’s called on.
19 20 21 22 23 |
# File 'lib/yaml_normalizer/ext/nested.rb', line 19 def nested tree = {} each { |key, val| nest_key(tree, key, val) } tree end |