summaryrefslogtreecommitdiff
path: root/lib/puppet/parser
diff options
context:
space:
mode:
authorJustin Burnham <jburnham@mediatemple.net>2014-02-17 11:46:55 -0800
committerJustin Burnham <jburnham@mediatemple.net>2014-02-17 12:19:40 -0800
commitc12e9afc97f4356bc20554d32861889680c5fdc1 (patch)
tree26af1eb65b781e8685172483b5b78cb461e1c826 /lib/puppet/parser
parentab981422a67636441f1bfebaaade36aa690f1f25 (diff)
downloadpuppet-stdlib-c12e9afc97f4356bc20554d32861889680c5fdc1.tar.gz
puppet-stdlib-c12e9afc97f4356bc20554d32861889680c5fdc1.tar.bz2
PUP-1724 Don't modify the paramaters to deep_merge
Instead of modifying the first paramater of deep_merge due to the use of the merge! function, instead use merge to return a copy of the merged object. This allows one to continue to use the original first parameter after the call to deep_merge.
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/functions/deep_merge.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/puppet/parser/functions/deep_merge.rb b/lib/puppet/parser/functions/deep_merge.rb
index 94677b8..6df32e9 100644
--- a/lib/puppet/parser/functions/deep_merge.rb
+++ b/lib/puppet/parser/functions/deep_merge.rb
@@ -20,7 +20,7 @@ module Puppet::Parser::Functions
end
deep_merge = Proc.new do |hash1,hash2|
- hash1.merge!(hash2) do |key,old_value,new_value|
+ hash1.merge(hash2) do |key,old_value,new_value|
if old_value.is_a?(Hash) && new_value.is_a?(Hash)
deep_merge.call(old_value, new_value)
else
@@ -37,7 +37,7 @@ module Puppet::Parser::Functions
raise Puppet::ParseError, "deep_merge: unexpected argument type #{arg.class}, only expects hash arguments"
end
- deep_merge.call(result, arg)
+ result = deep_merge.call(result, arg)
end
return( result )
end