Class: Substation::Environment::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/substation/environment/dsl.rb

Overview

The DSL class used to register processor builders

Constant Summary collapse

GUARD =

Rejects already registered and reserved names

Substation::DSL::Guard.new(Chain::DSL::BASE_METHODS)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry, &block) ⇒ 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


47
48
49
50
# File 'lib/substation/environment/dsl.rb', line 47

def initialize(registry, &block)
  @registry = registry
  instance_eval(&block) if block
end

Instance Attribute Details

#registryHash<Symbol, Processor::Builder> (readonly)

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.

The registry of processor builders


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

def registry
  @registry
end

Class Method Details

.registry(guard = GUARD, &block) ⇒ Hash<Symbol, Processor::Builder>

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.

The registry of processor builders


35
36
37
# File 'lib/substation/environment/dsl.rb', line 35

def self.registry(guard = GUARD, &block)
  new(Substation::DSL::Registry.new(guard), &block).registry
end

Instance Method Details

#register(name, processor, executor = Processor::Executor::NULL) ⇒ self

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.

Register a new processor using the given name and executor


66
67
68
69
70
71
72
73
# File 'lib/substation/environment/dsl.rb', line 66

def register(name, processor, executor = Processor::Executor::NULL)
  coerced_name = name.to_sym

  registry[coerced_name] =
    Processor::Builder.new(coerced_name, processor, executor)

  self
end