From 41a46b67aed703cd9311aa0c4e4b18ff81a75fa8 Mon Sep 17 00:00:00 2001 From: tphoney Date: Tue, 19 Jul 2016 11:56:09 +0100 Subject: (MODULES-3306) document deep_merge --- README.markdown | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.markdown b/README.markdown index f176d98..24f493c 100644 --- a/README.markdown +++ b/README.markdown @@ -245,6 +245,19 @@ Converts a given integer or base 10 string representing an integer to a specifie If called with only an array, it counts the number of elements that are **not** nil/undef. If called with a second argument, counts the number of elements in an array that matches the second argument. *Type*: rvalue. +#### `deep_merge` + +Recursively merges two or more hashes together and returns the resulting hash. + $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } + $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } } + $merged_hash = deep_merge($hash1, $hash2) + +The resulting hash is equivalent to: + $merged_hash = { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } + +When there is a duplicate key that is a hash, they are recursively merged. When there is a duplicate key that is not a hash, the key in the rightmost hash will "win.". +*Type*: rvalue, rvalue. + #### `defined_with_params` Takes a resource reference and an optional hash of attributes. Returns 'true' if a resource with the specified attributes has already been added to the catalog. Returns 'false' otherwise. -- cgit v1.2.3