summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/delete.rb
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2015-01-27 15:14:18 -0500
committerMicah Anderson <micah@riseup.net>2015-01-27 15:14:18 -0500
commit71123634744b9fe2ec7d6a3e38e9789fd84801e3 (patch)
tree1794e812d83facd93b3007c42632c63ddf1eb2fc /lib/puppet/parser/functions/delete.rb
parent71cb0f4c2c3bf95f62c9f189f5cef155b09a9682 (diff)
parent5863ab3901368310186790980aea2b0bf7cecb06 (diff)
Merge branch 'master' into leap
Diffstat (limited to 'lib/puppet/parser/functions/delete.rb')
-rw-r--r--lib/puppet/parser/functions/delete.rb29
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/puppet/parser/functions/delete.rb b/lib/puppet/parser/functions/delete.rb
index f814344..f548b44 100644
--- a/lib/puppet/parser/functions/delete.rb
+++ b/lib/puppet/parser/functions/delete.rb
@@ -17,27 +17,30 @@ string, or key from a hash.
delete({'a'=>1,'b'=>2,'c'=>3}, 'b')
Would return: {'a'=>1,'c'=>3}
+ delete({'a'=>1,'b'=>2,'c'=>3}, ['b','c'])
+ Would return: {'a'=>1}
+
delete('abracadabra', 'bra')
Would return: 'acada'
- EOS
+ EOS
) do |arguments|
if (arguments.size != 2) then
raise(Puppet::ParseError, "delete(): Wrong number of arguments "+
- "given #{arguments.size} for 2.")
+ "given #{arguments.size} for 2.")
end
- collection = arguments[0]
- item = arguments[1]
-
- case collection
- when Array, Hash
- collection.delete item
- when String
- collection.gsub! item, ''
- else
- raise(TypeError, "delete(): First argument must be an Array, " +
- "String, or Hash. Given an argument of class #{collection.class}.")
+ collection = arguments[0].dup
+ Array(arguments[1]).each do |item|
+ case collection
+ when Array, Hash
+ collection.delete item
+ when String
+ collection.gsub! item, ''
+ else
+ raise(TypeError, "delete(): First argument must be an Array, " +
+ "String, or Hash. Given an argument of class #{collection.class}.")
+ end
end
collection
end