diff options
author | Hunter Haugen <hunter@puppetlabs.com> | 2014-12-19 10:31:58 -0800 |
---|---|---|
committer | Hunter Haugen <hunter@puppetlabs.com> | 2014-12-19 10:31:58 -0800 |
commit | 69c42b7eef05e172227c6dcc1ce70f35a42e5398 (patch) | |
tree | 975a9d43b5eed5e88f22d0d6d5c081063a30f708 /lib/puppet | |
parent | 9febb8b262f76435b88267545a475f3003b0edae (diff) | |
parent | 8ec6f8dbfdaaa4b34030cbe1f4764c42c629240e (diff) | |
download | puppet-stdlib-69c42b7eef05e172227c6dcc1ce70f35a42e5398.tar.gz puppet-stdlib-69c42b7eef05e172227c6dcc1ce70f35a42e5398.tar.bz2 |
Merge pull request #392 from cyberious/MOD-1606
MODULES-1606 add ability to pass array to delete for items to delete
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/parser/functions/delete.rb | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/puppet/parser/functions/delete.rb b/lib/puppet/parser/functions/delete.rb index d03a293..a1e39ed 100644 --- a/lib/puppet/parser/functions/delete.rb +++ b/lib/puppet/parser/functions/delete.rb @@ -19,25 +19,25 @@ string, or key from a hash. 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 |