Sha256: 47468836c2601deb19e8af90011de0769a5d388bcf7a40a42c01b64a3961fa99

Contents?: true

Size: 727 Bytes

Versions: 21

Compression:

Stored size: 727 Bytes

Contents

module Puppet::Parser::Functions
  newfunction(:delete_values, :type => :rvalue, :doc => <<-EOS
Deletes all instances of a given value from a hash.

*Examples:*

    delete_values({'a'=>'A','b'=>'B','c'=>'C','B'=>'D'}, 'B')

Would return: {'a'=>'A','c'=>'C','B'=>'D'}

      EOS
    ) do |arguments|

    raise(Puppet::ParseError,
          "delete_values(): Wrong number of arguments given " +
          "(#{arguments.size} of 2)") if arguments.size != 2

    hash, item = arguments

    if not hash.is_a?(Hash)
      raise(TypeError, "delete_values(): First argument must be a Hash. " + \
                       "Given an argument of class #{hash.class}.")
    end
    hash.dup.delete_if { |key, val| item == val }
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
puppet-retrospec-1.8.0 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-1.7.0 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-1.6.1 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-1.6.0 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-1.5.0 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-1.4.1 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-1.4.0 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-1.3.2 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-1.3.1 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-1.3.0 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-1.2.1 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-1.2.0 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-1.1.0 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-1.0.0 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-0.12.1 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-0.12.0 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-0.11.0 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-0.10.0 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-0.9.1 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb
puppet-retrospec-0.9.0 spec/fixtures/modules/stdlib/lib/puppet/parser/functions/delete_values.rb