Class: Substation::Environment::DSL

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

Overview

The DSL class used to define register processors

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&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

Parameters:

  • block (Proc)

    a block to be instance_eval’ed



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

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

Instance Attribute Details

#registryHash<Symbol, #call> (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 processors

Returns:

  • (Hash<Symbol, #call>)


12
13
14
# File 'lib/substation/environment/dsl.rb', line 12

def registry
  @registry
end

Class Method Details

.registry(&block) ⇒ Hash<Symbol, #call>

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 processors

Parameters:

  • block (Proc)

    a block to be instance_eval’ed

Returns:

  • (Hash<Symbol, #call>)


23
24
25
# File 'lib/substation/environment/dsl.rb', line 23

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

Instance Method Details

#register(name, processor) ⇒ 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

Parameters:

  • name (#to_sym)

    the name to register the processor for

  • processor (#call)

    the processor to register for name

Returns:

  • (self)


51
52
53
54
# File 'lib/substation/environment/dsl.rb', line 51

def register(name, processor)
  @registry[name] = processor
  self
end