class Substation::Environment::DSL

The DSL class used to register processor builders

Constants

GUARD

Rejects already registered and reserved names

Attributes

guard[R]

The guard to use for rejecting invalid names

@return [Guard]

@api private

registry[R]

The registry of processor builders

@return [Hash<Symbol, Processor::Builder>]

@api private

Public Class Methods

new(registry, &block) click to toggle source

Initialize a new instance

@param [Proc] block

a block to be instance_eval'ed

@return [undefined]

@api private

# File lib/substation/environment/dsl.rb, line 47
def initialize(registry, &block)
  @registry = registry
  instance_eval(&block) if block
end
registry(guard = GUARD, &block) click to toggle source

The registry of processor builders

@param [Proc] block

a block to be instance_eval'ed

@return [Hash<Symbol, Processor::Builder>]

@api private

# File lib/substation/environment/dsl.rb, line 35
def self.registry(guard = GUARD, &block)
  new(Substation::DSL::Registry.new(guard), &block).registry
end

Public Instance Methods

register(name, processor, executor = Processor::Executor::NULL) click to toggle source

Register a new processor using the given name and executor

@param [#to_sym] name

the name to register the +processor+ for

@param [#call] processor

the processor to register for +name+

@param [Processor::Executor] executor

the executor for +processor+

@return [self]

@api private

# 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