Skip to content

amiel/collapse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Example

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']}

Author

Amiel Martin

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages