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
#arg_count, #initialize, #last_captures_rest, #optional_block_param, #param, #required_block_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)
540 541 542 543 544 |
# File 'lib/puppet/functions.rb', line 540 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)
549 550 551 552 553 |
# File 'lib/puppet/functions.rb', line 549 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.
532 533 534 535 536 |
# File 'lib/puppet/functions.rb', line 532 def scope_param() @injections << [:scope, 'scope', '', :dispatcher_internal] # mark what should be picked for this position when dispatching @weaving << [@injections.size()-1] end |