An open API service indexing awesome lists of open source software.

https://github.com/amiel/collapse

collapse! merges a sub-hash with self while applying set union to any common arrays. See the example, it will make more sense.
https://github.com/amiel/collapse

Last synced: 11 months ago
JSON representation

collapse! merges a sub-hash with self while applying set union to any common arrays. See the example, it will make more sense.

Awesome Lists containing this project

README

          

h2. Collapse

This gem adds a method @collapse!@ to Hash.
Using collapse! merges a sub-hash with self while applying set union to any common arrays.

h2. Example

h3. example_config.yml



:foo:
- a
- b
- d
:bar:
:foo:
- b
- d
- e



tmp = YAML.load_file 'example_config.yml'
tmp.inspect # => {:foo => ['a', 'b', 'd'], :bar => {:foo => ['b', 'd', 'e']}}
tmp.collapse! :bar
tmp.inspect # => {:foo => ['a', 'b', 'd', 'e']}

h2. Author

Amiel Martin