Class: Puppet::Pops::Binder::Producers::ProducerProducer
- Defined in:
- lib/puppet/pops/binder/producers.rb
Overview
A ProducerProducer creates a producer via another producer, and then uses this created producer to produce values. This is useful for custom production of series of values. On each request for a producer, this producer will reset its internal producer (i.e. restarting the series).
Instance Attribute Summary collapse
- #producer_producer ⇒ Object readonly
- #value_producer ⇒ Object readonly
Attributes inherited from Producer
Instance Method Summary collapse
-
#initialize(injector, binding, scope, options) ⇒ ProducerProducer
constructor
Creates new ProducerProducer given a producer.
-
#producer(scope) ⇒ Object
Updates the internal state to use a new instance of the wrapped producer.
Methods inherited from Producer
Constructor Details
#initialize(injector, binding, scope, options) ⇒ ProducerProducer
Creates new ProducerProducer given a producer.
431 432 433 434 435 436 437 438 439 440 |
# File 'lib/puppet/pops/binder/producers.rb', line 431 def initialize(injector, binding, scope, ) super unless producer_producer = [:producer_producer] raise ArgumentError, "The option :producer_producer must be set in a ProducerProducer" end raise ArgumentError, "Argument must be a Producer" unless producer_producer.is_a?(Producer) @producer_producer = producer_producer @value_producer = nil end |
Instance Attribute Details
#producer_producer ⇒ Object (readonly)
416 417 418 |
# File 'lib/puppet/pops/binder/producers.rb', line 416 def producer_producer @producer_producer end |
#value_producer ⇒ Object (readonly)
419 420 421 |
# File 'lib/puppet/pops/binder/producers.rb', line 419 def value_producer @value_producer end |
Instance Method Details
#producer(scope) ⇒ Object
Updates the internal state to use a new instance of the wrapped producer.
445 446 447 448 |
# File 'lib/puppet/pops/binder/producers.rb', line 445 def producer(scope) @value_producer = @producer_producer.produce(scope) self end |