Class: Puppet::Pops::Binder::BindingsFactory::BindingsContainerBuilder

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

Overview

A bindings builder for an AbstractBinding containing other AbstractBinding instances.

Instance Attribute Summary

Attributes inherited from AbstractBuilder

#model

Instance Method Summary collapse

Methods inherited from AbstractBuilder

#initialize, #method_missing

Constructor Details

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

Dynamic Method Handling

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

Instance Method Details

#bind(&block) ⇒ BindingsBuilder

Adds an empty binding to the container, and returns a builder for it for further detailing. An optional block may be given which is evaluated using ‘instance_eval`.

Returns:



136
137
138
139
140
141
142
# File 'lib/puppet/pops/binder/bindings_factory.rb', line 136

def bind(&block)
  binding = Bindings::Binding.new()
  model.addBindings(binding)
  builder = BindingsBuilder.new(binding)
  builder.instance_eval(&block) if block_given?
  builder
end

#multibind(id, &block) ⇒ MultibindingsBuilder

Binds a multibind with the given identity where later, the looked up result contains all contributions to this key. An optional block may be given which is evaluated using ‘instance_eval`.

Parameters:

  • id (String)

    the multibind’s id used when adding contributions

Returns:



150
151
152
153
154
155
156
157
# File 'lib/puppet/pops/binder/bindings_factory.rb', line 150

def multibind(id, &block)
  binding = Bindings::Multibinding.new()
  binding.id = id
  model.addBindings(binding)
  builder = MultibindingsBuilder.new(binding)
  builder.instance_eval(&block) if block_given?
  builder
end