class Puppet::Functions::InternalDispatchBuilder

Injection and Weaving of parameters


It is possible to inject and weave a set of well known parameters into a call. These extra parameters are not part of the parameters passed from the Puppet logic, and they can not be overridden by parameters given as arguments in the call. They are invisible to the Puppet Language.

@example using injected parameters

Puppet::Functions.create_function('test') do
  dispatch :test do
    param 'Scalar', 'a'
    param 'Scalar', 'b'
    scope_param
  end
  def test(a, b, scope)
    a > b ? scope['a'] : scope['b']
  end
end

The function in the example above is called like this:

test(10, 20)

@api private

Public Instance Methods

cache_param() click to toggle source

Inject a parameter getting a cached hash for this function

    # File lib/puppet/functions.rb
841 def cache_param
842   inject(:cache)
843 end
compiler_param() click to toggle source

Inject parameter for `Puppet::Pal::CatalogCompiler`

    # File lib/puppet/functions.rb
846 def compiler_param
847   inject(:pal_catalog_compiler)
848 end
pal_compiler_param() click to toggle source

Inject parameter for either `Puppet::Pal::CatalogCompiler` or `Puppet::Pal::ScriptCompiler`

    # File lib/puppet/functions.rb
851 def pal_compiler_param
852   inject(:pal_compiler)
853 end
scope_param() click to toggle source

Inject parameter for `Puppet::Parser::Scope`

    # File lib/puppet/functions.rb
831 def scope_param
832   inject(:scope)
833 end
script_compiler_param() click to toggle source

Inject parameter for `Puppet::Pal::ScriptCompiler`

    # File lib/puppet/functions.rb
836 def script_compiler_param
837   inject(:pal_script_compiler)
838 end

Private Instance Methods

inject(injection_name) click to toggle source
    # File lib/puppet/functions.rb
857 def inject(injection_name)
858   @injections << injection_name
859   # mark what should be picked for this position when dispatching
860   @weaving << [@injections.size()-1]
861 end