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, "delete_values(): Wrong number of arguments given (#{arguments.size} of 2)") if arguments.size != 2
16 hash, item = arguments
18 if not hash.is_a?(Hash)
19 raise(TypeError, "delete_values(): First argument must be a Hash. Given an argument of class #{hash.class}.")
21 hash.dup.delete_if { |key, val| item == val }