Class: Puppet::Functions::InternalFunction Private
- Inherits:
-
Function
- Object
- Pops::Functions::Function
- Function
- Puppet::Functions::InternalFunction
- 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.
This is a private, internal, system for creating functions. It supports everything that the public function definition system supports as well as a few extra features.
Injection Support
The Function API supports injection of data and services. It is possible to make injection that takes effect when the function is loaded (for services and runtime configuration that does not change depending on how/from where in what context the function is called. It is also possible to inject and weave argument values into a call.
Injection of attributes
Injection of attributes is performed by one of the methods ‘attr_injected`, and `attr_injected_producer`. The injected attributes are available via accessor method calls.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Pops::Functions::Function
Class Method Summary collapse
-
.attr_injected(type, attribute_name, injection_name = nil) ⇒ Object
private
Defines class level injected attribute with reader method.
-
.attr_injected_producer(type, attribute_name, injection_name = nil) ⇒ Object
private
Defines class level injected producer attribute with reader method.
- .builder ⇒ Object private
Instance Method Summary collapse
-
#call_function_with_scope(scope, function_name, *args) ⇒ Object
Allows the implementation of a function to call other functions by name and pass the caller scope.
Methods inherited from Function
Methods inherited from Pops::Functions::Function
#call, #call_function, dispatcher, #initialize, signatures
Constructor Details
This class inherits a constructor from Puppet::Pops::Functions::Function
Class Method Details
.attr_injected(type, attribute_name, injection_name = nil) ⇒ 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.
Defines class level injected attribute with reader method
544 545 546 547 548 549 550 551 552 553 |
# File 'lib/puppet/functions.rb', line 544 def self.attr_injected(type, attribute_name, injection_name = nil) define_method(attribute_name) do ivar = :"@#{attribute_name.to_s}" unless instance_variable_defined?(ivar) injector = Puppet.lookup(:injector) instance_variable_set(ivar, injector.lookup(closure_scope, type, injection_name)) end instance_variable_get(ivar) end end |
.attr_injected_producer(type, attribute_name, injection_name = nil) ⇒ 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.
Defines class level injected producer attribute with reader method
558 559 560 561 562 563 564 565 566 567 |
# File 'lib/puppet/functions.rb', line 558 def self.attr_injected_producer(type, attribute_name, injection_name = nil) define_method(attribute_name) do ivar = :"@#{attribute_name.to_s}" unless instance_variable_defined?(ivar) injector = Puppet.lookup(:injector) instance_variable_set(ivar, injector.lookup_producer(closure_scope, type, injection_name)) end instance_variable_get(ivar) end end |
.builder ⇒ 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.
535 536 537 538 539 |
# File 'lib/puppet/functions.rb', line 535 def self.builder @type_parser ||= Puppet::Pops::Types::TypeParser.new @all_callables ||= Puppet::Pops::Types::TypeFactory.all_callables InternalDispatchBuilder.new(dispatcher, @type_parser, @all_callables, loader) end |
Instance Method Details
#call_function_with_scope(scope, function_name, *args) ⇒ Object
Allows the implementation of a function to call other functions by name and pass the caller scope. The callable functions are those visible to the same loader that loaded this function (the calling function).
579 580 581 |
# File 'lib/puppet/functions.rb', line 579 def call_function_with_scope(scope, function_name, *args) internal_call_function(scope, function_name, args) end |