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.
- Host: GitHub
- URL: https://github.com/amiel/collapse
- Owner: amiel
- Created: 2009-04-18T01:57:49.000Z (about 17 years ago)
- Default Branch: master
- Last Pushed: 2009-04-18T08:57:49.000Z (about 17 years ago)
- Last Synced: 2025-06-28T22:48:06.215Z (12 months ago)
- Language: Ruby
- Homepage:
- Size: 82 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.textile
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