Class: Puppet::Pops::Binder::Producers::MultibindProducer Abstract

Inherits:
AbstractArgumentedProducer show all
Defined in:
lib/puppet/pops/binder/producers.rb

Overview

This class is abstract.

Abstract base class for multibind producers. Is suitable as base class for custom implementations of multibind producers.

Instance Attribute Summary collapse

Attributes inherited from AbstractArgumentedProducer

#binding, #injector

Attributes inherited from Producer

#transformer

Instance Method Summary collapse

Methods inherited from Producer

#produce, #producer

Constructor Details

#initialize(injector, binding, scope, options) ⇒ MultibindProducer

Returns a new instance of MultibindProducer.

Parameters:

  • injector (Injector)

    The injector where the lookup originates

  • binding (Bindings::Binding, nil)

    The binding using this producer

  • scope (Puppet::Parser::Scope)

    The scope to use for evaluation

  • options (Hash)

    a customizable set of options

Options Hash (options):



525
526
527
528
# File 'lib/puppet/pops/binder/producers.rb', line 525

def initialize(injector, binding, scope, options)
  super
  @contributions_key = injector.key_factory.multibind_contributions(binding.id)
end

Instance Attribute Details

#contributions_keyObject (readonly)



516
517
518
# File 'lib/puppet/pops/binder/producers.rb', line 516

def contributions_key
  @contributions_key
end

Instance Method Details

#type_error_detail(expected, actual) ⇒ String

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.

Returns a formatted string for inclusion as detail in an error message.

Parameters:

Returns:

  • (String)

    a formatted string for inclusion as detail in an error message



535
536
537
538
539
540
541
# File 'lib/puppet/pops/binder/producers.rb', line 535

def type_error_detail(expected, actual)
  tc = injector.type_calculator
  expected = [expected] unless expected.is_a?(Array)
  actual_t = tc.is_ptype?(actual) ? actual : tc.infer(actual)
  expstrs = expected.collect {|t| t.to_s }
  "expected: #{expstrs.join(', or ')}, got: #{actual_t}"
end