Class: Puppet::Functions::InternalDispatchBuilder Private
- Inherits:
-
DispatcherBuilder
- Object
- DispatcherBuilder
- Puppet::Functions::InternalDispatchBuilder
- Defined in:
- lib/puppet/functions.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
WARNING: This style of creating functions is not public. It is a system under development that will be used for creating “system” functions.
Injection and Weaving of parameters
It is possible to inject and weave 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.
The function in the example above is called like this:
test(10, 20)
Using injected value as default
Default value assignment is handled by using the regular Ruby mechanism (a value is assigned to the variable). The dispatch simply indicates that the value is optional. If the default value should be injected, it can be handled different ways depending on what is desired:
-
by calling the accessor method for an injected Function class attribute. This is suitable if the value is constant across all instantiations of the function, and across all calls.
-
by injecting a parameter into the call to the left of the parameter, and then assigning that as the default value.
-
One of the above forms, but using an injected producer instead of a directly injected value.
Instance Method Summary collapse
-
#injected_param(type, name, injection_name = '') ⇒ Object
private
TODO: is param name really needed? Perhaps for error messages? (it is unused now).
-
#injected_producer_param(type, name, injection_name = '') ⇒ Object
private
TODO: is param name really needed? Perhaps for error messages? (it is unused now).
- #scope_param ⇒ Object private
Methods inherited from DispatcherBuilder
#block_param, #initialize, #optional_block_param, #optional_param, #param, #repeated_param, #required_repeated_param
Constructor Details
This class inherits a constructor from Puppet::Functions::DispatcherBuilder
Instance Method Details
#injected_param(type, name, injection_name = '') ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
TODO: is param name really needed? Perhaps for error messages? (it is unused now)
615 616 617 618 619 |
# File 'lib/puppet/functions.rb', line 615 def injected_param(type, name, injection_name = '') @injections << [type, name, injection_name] # mark what should be picked for this position when dispatching @weaving << [@injections.size() -1] end |
#injected_producer_param(type, name, injection_name = '') ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
TODO: is param name really needed? Perhaps for error messages? (it is unused now)
624 625 626 627 628 |
# File 'lib/puppet/functions.rb', line 624 def injected_producer_param(type, name, injection_name = '') @injections << [type, name, injection_name, :producer] # mark what should be picked for this position when dispatching @weaving << [@injections.size()-1] end |
#scope_param ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
607 608 609 610 611 |
# File 'lib/puppet/functions.rb', line 607 def scope_param() @injections << [:scope, 'scope', '', :dispatcher_internal] # mark what should be picked for this position when dispatching @weaving << [@injections.size()-1] end |