summaryrefslogtreecommitdiff
path: root/README.markdown
diff options
context:
space:
mode:
authortphoney <tp@puppet.com>2016-07-19 11:56:09 +0100
committertphoney <tp@puppet.com>2016-07-19 11:56:09 +0100
commit41a46b67aed703cd9311aa0c4e4b18ff81a75fa8 (patch)
tree94014d70d58f0ae98af20ccb46efc627183f29de /README.markdown
parent01bc41e73621fa07d0b14b3b3fa8a75e666a7df5 (diff)
(MODULES-3306) document deep_merge
Diffstat (limited to 'README.markdown')
-rw-r--r--README.markdown13
1 files changed, 13 insertions, 0 deletions
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.