chef
https://github.com/opscode/chef
Ruby
A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.
Chef::Mixin::DeepMerge#deep_merge!
Deep Merge core documentation.
deep_merge! method permits merging of arbitrary child elements. The two top level
elements must be hashes. These hashes can contain unlimited (to stack limit) levels
of child elements. These child elements to not have to be of the same types.
Where child elements are of the same type, deep_merge will attempt to merge them together.
Where child elements are not of the same type, deep_merge will skip or optionally overwrite
the destination element with the contents of the source element at that level.
So if you have two hashes like this:
source = {:x => [1,2,3], :y => 2}
dest = {:x => [4,5,'6'], :y => [7,8,9]}
dest.deep_merge!(source)
Results: {:x => [1,2,3,4,5,'6'], :y => 2}
By default, "deep_merge!" will overwrite any unmergeables and merge everything else.
To avoid this, use "deep_merge" (no bang/exclamation mark)Edit
git clone [email protected]:opscode/chef.git
cd chef
open lib/chef/mixin/deep_merge.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Chef--Mixin--DeepMerge-deep_merge--for-pr
# Commit to gitgit add lib/chef/mixin/deep_merge.rbgit commit -m "better docs for Chef::Mixin::DeepMerge#deep_merge!"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Chef--Mixin--DeepMerge-deep_merge--for-pr
hub pull-request
# Celebrate!