Sha256: 49a77b421385f0aee4d9b17d068e1bea5b96a3ab0b22facfed7e190ab141f3d6

Contents?: true

Size: 596 Bytes

Versions: 26

Compression:

Stored size: 596 Bytes

Contents

# Call a lambda with the given arguments. Since the parameters of the lambda
# are local to the lambda's scope, this can be used to create private sections
# of logic in a class so that the variables are not visible outside of the
# class.
#
# @example Using with
#
#     # notices the array [1, 2, 'foo']
#     with(1, 2, 'foo') |$x, $y, $z| { notice [$x, $y, $z] }
#
# @since 3.7.0
#
Puppet::Functions.create_function(:with) do
  dispatch :with do
    param 'Any', 'arg'
    arg_count(0, :default)
    required_block_param
  end

  def with(*args)
    args[-1].call({}, *args[0..-2])
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
puppet-retrospec-0.12.2 vendor/gems/puppet-3.7.3/lib/puppet/functions/with.rb
puppet-retrospec-0.12.1 vendor/gems/puppet-3.7.3/lib/puppet/functions/with.rb
puppet-retrospec-0.12.0 vendor/gems/puppet-3.7.3/lib/puppet/functions/with.rb
puppet-retrospec-0.11.0 vendor/gems/puppet-3.7.3/lib/puppet/functions/with.rb
puppet-retrospec-0.10.0 vendor/gems/puppet-3.7.3/lib/puppet/functions/with.rb
puppet-retrospec-0.9.1 vendor/gems/puppet-3.7.3/lib/puppet/functions/with.rb
puppet-retrospec-0.9.0 vendor/gems/puppet-3.7.3/lib/puppet/functions/with.rb
puppet-retrospec-0.8.1 vendor/gems/puppet-3.7.3/lib/puppet/functions/with.rb
puppet-retrospec-0.8.0 vendor/gems/puppet-3.7.3/lib/puppet/functions/with.rb
puppet-retrospec-0.7.3 vendor/gems/puppet-3.7.3/lib/puppet/functions/with.rb
puppet-retrospec-0.7.2 vendor/gems/puppet-3.7.3/lib/puppet/functions/with.rb
puppet-3.7.4 lib/puppet/functions/with.rb
puppet-3.7.4-x86-mingw32 lib/puppet/functions/with.rb
puppet-3.7.4-x64-mingw32 lib/puppet/functions/with.rb
puppet-3.7.3 lib/puppet/functions/with.rb
puppet-3.7.3-x86-mingw32 lib/puppet/functions/with.rb
puppet-3.7.3-x64-mingw32 lib/puppet/functions/with.rb
puppet-3.7.2 lib/puppet/functions/with.rb
puppet-3.7.2-x86-mingw32 lib/puppet/functions/with.rb
puppet-3.7.2-x64-mingw32 lib/puppet/functions/with.rb