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:

Options Hash (options):



522
523
524
525
# File 'lib/puppet/pops/binder/producers.rb', line 522

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

Instance Attribute Details

#contributions_keyObject (readonly)



513
514
515
# File 'lib/puppet/pops/binder/producers.rb', line 513

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



532
533
534
535
536
537
538
# File 'lib/puppet/pops/binder/producers.rb', line 532

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| tc.string(t) }
  "expected: #{expstrs.join(', or ')}, got: #{tc.string(actual_t)}"
end