1 module Puppet::Parser::Functions
2 newfunction(:delete_values, :type => :rvalue, :doc => <<-EOS
3 Deletes all instances of a given value from a hash.
7 delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')
9 Would return: {'a'=>'A','c'=>'C','B'=>'D'}
14 raise(Puppet::ParseError,
15 "delete_values(): Wrong number of arguments given " +
16 "(#{arguments.size} of 2)") if arguments.size != 2
18 hash, item = arguments
20 if not hash.is_a?(Hash)
21 raise(TypeError, "delete_values(): First argument must be a Hash. " + \
22 "Given an argument of class #{hash.class}.")
24 hash.dup.delete_if { |key, val| item == val }