This type of producer should only be created by the Injector.
@api private
# File lib/puppet/pops/binder/producers.rb, line 479 def produce(scope, *args) producer(scope, *args) unless @inst @inst end
@api private
# File lib/puppet/pops/binder/producers.rb, line 485 def producer(scope, *args) @inst = nil # A class :inject method wins over an instance :initialize if it is present, unless a more specific zero args # constructor exists. (i.e do not pick :inject from superclass if class has a zero args constructor). # if @clazz.respond_to?(:inject) inject_method = @clazz.method(:inject) initialize_method = @clazz.instance_method(:initialize) if inject_method.owner <= initialize_method.owner || initialize_method.arity != 0 @inst = @clazz.inject(@injector, scope, nil, *args) end end if @inst.nil? unless args.empty? raise ArgumentError, "Assisted Inject can not pass arguments to no-args constructor when there is no class inject method." end @inst = @clazz.new() end self end
An Assisted Inject Producer is created when a lookup is made of a type that is not bound. It does not support a transformer lambda. @note This initializer has a different signature than all others. Do not use in regular logic. @api private
# File lib/puppet/pops/binder/producers.rb, line 471 def initialize(injector, clazz) raise ArgumentError, "class must be given" unless clazz.is_a?(Class) @injector = injector @clazz = clazz @inst = nil end