Class: Puppet::Pops::Binder::BindingsFactory::MultibindingsBuilder

Inherits:
BindingsBuilder show all
Defined in:
lib/puppet/pops/binder/bindings_factory.rb

Overview

A builder specialized for multibind - checks that type is Array or Hash based. A new builder sets the multibinding to be of type Hash.

Instance Attribute Summary

Attributes inherited from AbstractBuilder

#model

Instance Method Summary collapse

Methods inherited from BindingsBuilder

#abstract, #array_of, #array_of_data, #boolean, #final, #float, #hash_of, #hash_of_data, #in_multibind, #initialize, #instance_of, #integer, #name, #override, #pattern, #producer_options, #scalar, #string, #to, #to_first_found, #to_hash_lookup_of, #to_instance, #to_lookup_of, #to_producer, #to_producer_series, #to_series_of, #type_factory

Methods inherited from AbstractBuilder

#initialize, #method_missing

Constructor Details

This class inherits a constructor from Puppet::Pops::Binder::BindingsFactory::BindingsBuilder

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Puppet::Pops::Binder::BindingsFactory::AbstractBuilder

Instance Method Details

#dataObject

Overrides the default implementation that will raise an exception as a multibind requires a hash type. Thus, if nothing else is requested, a multibind will be configured as Hash.



591
592
593
# File 'lib/puppet/pops/binder/bindings_factory.rb', line 591

def data()
  hash_of_data()
end

#type(type) ⇒ Object

Constraints type to be one of PArrayType, or PHashType.

Raises:

  • (ArgumentError)

    if type constraint is not met.



580
581
582
583
584
585
586
# File 'lib/puppet/pops/binder/bindings_factory.rb', line 580

def type(type)
  unless type.class == Puppet::Pops::Types::PArrayType || type.class == Puppet::Pops::Types::PHashType
    raise ArgumentError, "Wrong type; only PArrayType, or PHashType allowed, got '#{type.to_s}'"
  end
  model.type = type
  self
end