class Substation::Chain::DSL::ModuleBuilder
Builds a {Module} suitable for a {DSL} instance
Attributes
dsl_module[R]
A module suitable for inclusion in a {DSL} instance
@return [Module]
@api private
Public Class Methods
call(registry)
click to toggle source
Builds a new {Module} targeted for a {DSL} instance
@param [Hash<Symbol, Processor::Builder>] registry
the registry of processor builders used in an {Environment}
@return [Module]
@api private
# File lib/substation/chain/dsl/module_builder.rb, line 18 def self.call(registry) new(registry).dsl_module end
new(registry)
click to toggle source
Initialize a new instance
@param [Hash<Symbol, Processor::Builder>] registry
the registry of processor builders to define methods for
@return [undefined]
@api private
# File lib/substation/chain/dsl/module_builder.rb, line 39 def initialize(registry) @registry = registry @dsl_module = Module.new initialize_dsl_module end
Private Instance Methods
define_dsl_method(name, builder)
click to toggle source
Define a new instance method on the dsl
module
@param [Symbol] name
the name of the method
@param [Processor::Builder] builder
the processor builder to use within the chain
@param [Module] dsl
the module to define the method on
@return [undefined]
@api private
# File lib/substation/chain/dsl/module_builder.rb, line 73 def define_dsl_method(name, builder) @dsl_module.module_eval do define_method(name) { |handler, failure_chain = EMPTY, observers = EMPTY_ARRAY| use(builder.call(handler, failure_chain, observers)) } end end
initialize_dsl_module()
click to toggle source
Compile a new module for inclusion into a {DSL} instance
@param [Hash<Symbol, Processor::Builder>] registry
the registry of processor builders to define methods for
@return [undefined]
@api private
# File lib/substation/chain/dsl/module_builder.rb, line 55 def initialize_dsl_module @registry.each { |pair| define_dsl_method(*pair) } end