Class: Substation::Environment

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/substation/environment.rb,
lib/substation/environment/dsl.rb

Overview

The environment holding all registered Chain processors

Defined Under Namespace

Classes: DSL

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry) ⇒ undefined

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.

Initialize a new instance

Parameters:

  • registry (Hash<Symbol, #call>)

    the registry of processors



29
30
31
32
# File 'lib/substation/environment.rb', line 29

def initialize(registry)
  @registry  = registry
  @chain_dsl = Chain::DSL::Builder.call(@registry)
end

Class Method Details

.build(&block) ⇒ Environment

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.

Build a new Substation::Environment instance

Parameters:

  • block (Proc)

    a block to be instance_eval’ed with DSL

Returns:



17
18
19
# File 'lib/substation/environment.rb', line 17

def self.build(&block)
  new(DSL.registry(&block))
end

Instance Method Details

#chain(other = Chain::EMPTY, &block) ⇒ Chain

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.

Build a new Chain instance

Parameters:

  • other (Chain) (defaults to: Chain::EMPTY)

    the optional chain to build on top of

  • block (Proc)

    a block to be instance_eval’ed in Chain::DSL

Returns:



45
46
47
# File 'lib/substation/environment.rb', line 45

def chain(other = Chain::EMPTY, &block)
  Chain.build(@chain_dsl, other, &block)
end