Sha256: 074a39458daf91b0192733a779eb8dbb1f2a7e339fafc879366b0b6484c08642

Contents?: true

Size: 1.02 KB

Versions: 51

Compression:

Stored size: 1.02 KB

Contents

# Calls an arbitrary Puppet function by name.
#
# This function takes one mandatory argument and one or more optional arguments:
#
# 1. A string corresponding to a function name.
# 2. Any number of arguments to be passed to the called function.
# 3. An optional lambda, if the function being called supports it.
#
# @example Using the `call` function
#
# ```puppet
# $a = 'notice'
# call($a, 'message')
# ```
#
# @example Using the `call` function with a lambda
#
# ```puppet
# $a = 'each'
# $b = [1,2,3]
# call($a, $b) |$item| {
#  notify { $item: }
# }
# ```
#
# The `call` function can be used to call either Ruby functions or Puppet language
# functions.
#
# @since 5.0.0
#
Puppet::Functions.create_function(:call, Puppet::Functions::InternalFunction) do
  dispatch :call_impl_block do
    scope_param
    param 'String', :function_name
    repeated_param 'Any', :arguments
    optional_block_param
  end

  def call_impl_block(scope, function_name, *args, &block)
    call_function_with_scope(scope, function_name, *args, &block)
  end
end

Version data entries

51 entries across 51 versions & 2 rubygems

Version Path
puppet-5.5.10 lib/puppet/functions/call.rb
puppet-5.5.10-x86-mingw32 lib/puppet/functions/call.rb
puppet-5.5.10-x64-mingw32 lib/puppet/functions/call.rb
puppet-5.5.10-universal-darwin lib/puppet/functions/call.rb
puppet-5.5.8 lib/puppet/functions/call.rb
puppet-5.5.8-x86-mingw32 lib/puppet/functions/call.rb
puppet-5.5.8-x64-mingw32 lib/puppet/functions/call.rb
puppet-5.5.8-universal-darwin lib/puppet/functions/call.rb
puppet-5.5.7 lib/puppet/functions/call.rb
puppet-5.5.7-x86-mingw32 lib/puppet/functions/call.rb
puppet-5.5.7-x64-mingw32 lib/puppet/functions/call.rb
puppet-5.5.7-universal-darwin lib/puppet/functions/call.rb
puppet-5.5.6 lib/puppet/functions/call.rb
puppet-5.5.6-x86-mingw32 lib/puppet/functions/call.rb
puppet-5.5.6-x64-mingw32 lib/puppet/functions/call.rb
puppet-5.5.6-universal-darwin lib/puppet/functions/call.rb
bolt-0.21.7 vendored/puppet/lib/puppet/functions/call.rb
bolt-0.21.6 vendored/puppet/lib/puppet/functions/call.rb
bolt-0.21.5 vendored/puppet/lib/puppet/functions/call.rb
bolt-0.21.4 vendored/puppet/lib/puppet/functions/call.rb