danielsdeleo/deep_merge — pull request #18 by pkill (2014-11-10 19:29:22+00:00)
Title: Preserve the knockout element if the element doesn't exist in the destin...

...ation array

For an array inside of a hash, if the source array contains a knockout item (#{knockout_prefix}item) but the destination array doesn't contain the item to be knocked out, the default behavior is for deep merge to eliminate the knockout item regardless of annihilation.

This patch does not change the default behavior but introduces and option, preserve_knockout, that changes the behavior to preserve the knockout item in the result array.

This is useful for users of puppetlabs-hiera which uses deep_merge for merging Hiera arrays. Hiera passes the result array back into deep_merge on successful iterations while merging in new destination arrays as the hierarchy is traversed during Puppet catalog compilation.