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 Attribute Summary
Attributes inherited from DispatcherBuilder
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, #return_type
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)
730 731 732 733 734 |
# File 'lib/puppet/functions.rb', line 730 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)
739 740 741 742 743 |
# File 'lib/puppet/functions.rb', line 739 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.
722 723 724 725 726 |
# File 'lib/puppet/functions.rb', line 722 def scope_param() @injections << [:scope, 'scope', '', :dispatcher_internal] # mark what should be picked for this position when dispatching @weaving << [@injections.size()-1] end |