diff options
author | Colleen Murphy <cmurphy@users.noreply.github.com> | 2015-01-13 17:43:19 -0800 |
---|---|---|
committer | Colleen Murphy <cmurphy@users.noreply.github.com> | 2015-01-13 17:43:19 -0800 |
commit | 712a58a5ce1f8465710dacad49ca2e60c5d0150e (patch) | |
tree | 7e56b669bf51eb88ee01a5cbc1f84df5766ebf1c /lib/puppet/parser/functions/delete.rb | |
parent | 80f09623b63cf6946b5913b629911e2c49b5d1dd (diff) | |
parent | cfacdd543e942f7c5d94fd07f14c2f6d8128e83d (diff) |
Merge pull request #397 from cyberious/4.6.x
4.6.x
Diffstat (limited to 'lib/puppet/parser/functions/delete.rb')
-rw-r--r-- | lib/puppet/parser/functions/delete.rb | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/puppet/parser/functions/delete.rb b/lib/puppet/parser/functions/delete.rb index d03a293..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].dup - 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}.") + 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 |