substation 0.0.10.beta2 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. data/.travis.yml +7 -3
  2. data/Changelog.md +99 -24
  3. data/Gemfile +8 -1
  4. data/Gemfile.devtools +37 -21
  5. data/Guardfile +1 -1
  6. data/README.md +118 -46
  7. data/TODO.md +1 -0
  8. data/config/flay.yml +2 -2
  9. data/config/flog.yml +1 -1
  10. data/config/reek.yml +41 -16
  11. data/config/rubocop.yml +44 -0
  12. data/config/yardstick.yml +1 -1
  13. data/lib/substation.rb +41 -5
  14. data/lib/substation/chain.rb +73 -84
  15. data/lib/substation/chain/definition.rb +147 -0
  16. data/lib/substation/chain/dsl.rb +150 -112
  17. data/lib/substation/chain/dsl/config.rb +55 -0
  18. data/lib/substation/chain/dsl/module_builder.rb +84 -0
  19. data/lib/substation/dispatcher.rb +20 -229
  20. data/lib/substation/dsl/guard.rb +96 -0
  21. data/lib/substation/dsl/registry.rb +181 -0
  22. data/lib/substation/environment.rb +126 -23
  23. data/lib/substation/environment/dsl.rb +31 -12
  24. data/lib/substation/processor.rb +238 -7
  25. data/lib/substation/processor/builder.rb +26 -0
  26. data/lib/substation/processor/config.rb +24 -0
  27. data/lib/substation/processor/evaluator.rb +66 -42
  28. data/lib/substation/processor/evaluator/handler.rb +54 -0
  29. data/lib/substation/processor/evaluator/result.rb +24 -0
  30. data/lib/substation/processor/executor.rb +46 -0
  31. data/lib/substation/processor/nest.rb +40 -0
  32. data/lib/substation/processor/transformer.rb +46 -0
  33. data/lib/substation/processor/wrapper.rb +16 -5
  34. data/lib/substation/request.rb +29 -27
  35. data/lib/substation/response.rb +19 -34
  36. data/lib/substation/response/api.rb +37 -0
  37. data/lib/substation/response/exception.rb +20 -0
  38. data/lib/substation/response/exception/output.rb +59 -0
  39. data/lib/substation/response/failure.rb +11 -0
  40. data/lib/substation/response/success.rb +11 -0
  41. data/lib/substation/version.rb +3 -1
  42. data/spec/demo/core.rb +64 -0
  43. data/spec/demo/core/action.rb +49 -0
  44. data/spec/demo/core/action/create_person.rb +28 -0
  45. data/spec/demo/core/errors.rb +16 -0
  46. data/spec/demo/core/facade.rb +38 -0
  47. data/spec/demo/core/handler.rb +21 -0
  48. data/spec/demo/core/handler/acceptor.rb +47 -0
  49. data/spec/demo/core/handler/authenticator.rb +36 -0
  50. data/spec/demo/core/handler/authorizer.rb +38 -0
  51. data/spec/demo/core/input.rb +15 -0
  52. data/spec/demo/core/observers.rb +10 -0
  53. data/spec/demo/core/validator.rb +21 -0
  54. data/spec/demo/domain/actor.rb +29 -0
  55. data/spec/demo/domain/dto/person.rb +18 -0
  56. data/spec/demo/domain/environment.rb +55 -0
  57. data/spec/demo/domain/storage.rb +49 -0
  58. data/spec/demo/web.rb +26 -0
  59. data/spec/demo/web/errors.rb +9 -0
  60. data/spec/demo/web/facade.rb +60 -0
  61. data/spec/demo/web/handler/deserializer.rb +36 -0
  62. data/spec/demo/web/presenter.rb +38 -0
  63. data/spec/demo/web/presenter/person.rb +19 -0
  64. data/spec/demo/web/renderer.rb +45 -0
  65. data/spec/demo/web/sanitizer.rb +35 -0
  66. data/spec/demo/web/sanitizer/person.rb +20 -0
  67. data/spec/demo/web/views.rb +28 -0
  68. data/spec/integration/demo/core_spec.rb +97 -0
  69. data/spec/integration/demo/web_spec.rb +114 -0
  70. data/spec/shared/context/integration/demo.rb +33 -0
  71. data/spec/shared/context/unit/chain.rb +13 -0
  72. data/spec/shared/context/unit/processor.rb +58 -0
  73. data/spec/shared/context/unit/request.rb +8 -0
  74. data/spec/shared/examples/integration/demo.rb +35 -0
  75. data/spec/shared/examples/unit/processor.rb +72 -0
  76. data/spec/spec_helper.rb +52 -23
  77. data/spec/unit/substation/chain/definition_spec.rb +141 -0
  78. data/spec/unit/substation/chain/dsl/config/dsl_module_spec.rb +13 -0
  79. data/spec/unit/substation/chain/dsl/config/registry_spec.rb +13 -0
  80. data/spec/unit/substation/chain/dsl/config_spec.rb +18 -0
  81. data/spec/unit/substation/chain/dsl/module_builder_spec.rb +77 -0
  82. data/spec/unit/substation/chain/dsl_spec.rb +175 -0
  83. data/spec/unit/substation/chain_spec.rb +303 -0
  84. data/spec/unit/substation/dispatcher_spec.rb +68 -0
  85. data/spec/unit/substation/dsl/guard_spec.rb +72 -0
  86. data/spec/unit/substation/dsl/registry_spec.rb +181 -0
  87. data/spec/unit/substation/environment/dsl_spec.rb +156 -0
  88. data/spec/unit/substation/environment_spec.rb +259 -0
  89. data/spec/unit/substation/processor/builder_spec.rb +21 -0
  90. data/spec/unit/substation/processor/config_spec.rb +40 -0
  91. data/spec/unit/substation/processor/evaluator/handler_spec.rb +20 -0
  92. data/spec/unit/substation/processor/evaluator/pivot_spec.rb +42 -0
  93. data/spec/unit/substation/processor/evaluator/request_spec.rb +11 -0
  94. data/spec/unit/substation/processor/evaluator/result/failure_spec.rb +14 -0
  95. data/spec/unit/substation/processor/evaluator/result/success_spec.rb +14 -0
  96. data/spec/unit/substation/processor/evaluator/result_spec.rb +13 -0
  97. data/spec/unit/substation/processor/evaluator_spec.rb +18 -0
  98. data/spec/unit/substation/processor/executor/null_spec.rb +25 -0
  99. data/spec/unit/substation/processor/executor_spec.rb +32 -0
  100. data/spec/unit/substation/processor/fallible_spec.rb +24 -0
  101. data/spec/unit/substation/processor/incoming_spec.rb +17 -0
  102. data/spec/unit/substation/processor/nest/incoming_spec.rb +56 -0
  103. data/spec/unit/substation/processor/nest_spec.rb +6 -0
  104. data/spec/unit/substation/processor/outgoing_spec.rb +47 -0
  105. data/spec/unit/substation/processor/transformer/incoming_spec.rb +17 -0
  106. data/spec/unit/substation/processor/transformer/outgoing_spec.rb +17 -0
  107. data/spec/unit/substation/processor/wrapper/incoming_spec.rb +15 -0
  108. data/spec/unit/substation/processor/wrapper/outgoing_spec.rb +15 -0
  109. data/spec/unit/substation/processor/wrapper_spec.rb +24 -0
  110. data/spec/unit/substation/processor_spec.rb +68 -0
  111. data/spec/unit/substation/request_spec.rb +70 -0
  112. data/spec/unit/substation/response/api_spec.rb +22 -0
  113. data/spec/unit/substation/response/exception/output_spec.rb +46 -0
  114. data/spec/unit/substation/response/exception_spec.rb +25 -0
  115. data/spec/unit/substation/response/failure_spec.rb +25 -0
  116. data/spec/unit/substation/response/success_spec.rb +24 -0
  117. data/spec/unit/substation/response_spec.rb +73 -0
  118. data/substation.gemspec +7 -6
  119. metadata +157 -67
  120. checksums.yaml +0 -7
  121. data/TODO +0 -0
  122. data/lib/substation/observer.rb +0 -66
  123. data/lib/substation/processor/pivot.rb +0 -25
  124. data/lib/substation/utils.rb +0 -68
  125. data/spec/integration/substation/dispatcher/call_spec.rb +0 -260
  126. data/spec/unit/substation/chain/call_spec.rb +0 -63
  127. data/spec/unit/substation/chain/dsl/builder/class_methods/call_spec.rb +0 -19
  128. data/spec/unit/substation/chain/dsl/builder/dsl_spec.rb +0 -21
  129. data/spec/unit/substation/chain/dsl/builder/failure_chain_spec.rb +0 -30
  130. data/spec/unit/substation/chain/dsl/chain_spec.rb +0 -15
  131. data/spec/unit/substation/chain/dsl/class_methods/processors_spec.rb +0 -24
  132. data/spec/unit/substation/chain/dsl/initialize_spec.rb +0 -19
  133. data/spec/unit/substation/chain/dsl/processors_spec.rb +0 -42
  134. data/spec/unit/substation/chain/dsl/use_spec.rb +0 -14
  135. data/spec/unit/substation/chain/each_spec.rb +0 -46
  136. data/spec/unit/substation/chain/incoming/result_spec.rb +0 -21
  137. data/spec/unit/substation/chain/outgoing/call_spec.rb +0 -25
  138. data/spec/unit/substation/chain/outgoing/result_spec.rb +0 -21
  139. data/spec/unit/substation/dispatcher/action/call_spec.rb +0 -23
  140. data/spec/unit/substation/dispatcher/action/class_methods/coerce_spec.rb +0 -61
  141. data/spec/unit/substation/dispatcher/action_names_spec.rb +0 -14
  142. data/spec/unit/substation/dispatcher/call_spec.rb +0 -47
  143. data/spec/unit/substation/dispatcher/class_methods/coerce_spec.rb +0 -20
  144. data/spec/unit/substation/environment/chain_spec.rb +0 -50
  145. data/spec/unit/substation/environment/class_methods/build_spec.rb +0 -11
  146. data/spec/unit/substation/environment/dsl/class_methods/registry_spec.rb +0 -18
  147. data/spec/unit/substation/environment/dsl/register_spec.rb +0 -14
  148. data/spec/unit/substation/environment/dsl/registry_spec.rb +0 -19
  149. data/spec/unit/substation/observer/chain/call_spec.rb +0 -26
  150. data/spec/unit/substation/observer/class_methods/coerce_spec.rb +0 -33
  151. data/spec/unit/substation/observer/null/call_spec.rb +0 -12
  152. data/spec/unit/substation/processor/evaluator/call_spec.rb +0 -49
  153. data/spec/unit/substation/processor/pivot/call_spec.rb +0 -17
  154. data/spec/unit/substation/processor/wrapper/call_spec.rb +0 -20
  155. data/spec/unit/substation/request/env_spec.rb +0 -14
  156. data/spec/unit/substation/request/error_spec.rb +0 -15
  157. data/spec/unit/substation/request/input_spec.rb +0 -14
  158. data/spec/unit/substation/request/success_spec.rb +0 -15
  159. data/spec/unit/substation/response/env_spec.rb +0 -16
  160. data/spec/unit/substation/response/failure/success_predicate_spec.rb +0 -15
  161. data/spec/unit/substation/response/input_spec.rb +0 -16
  162. data/spec/unit/substation/response/output_spec.rb +0 -16
  163. data/spec/unit/substation/response/request_spec.rb +0 -16
  164. data/spec/unit/substation/response/success/success_predicate_spec.rb +0 -15
  165. data/spec/unit/substation/utils/class_methods/coerce_callable_spec.rb +0 -46
  166. data/spec/unit/substation/utils/class_methods/const_get_spec.rb +0 -46
  167. data/spec/unit/substation/utils/class_methods/symbolize_keys_spec.rb +0 -20
@@ -0,0 +1,181 @@
1
+ # encoding: utf-8
2
+
3
+ module Substation
4
+ module DSL
5
+
6
+ # A mutable registry for objects collected with DSL classes
7
+ class Registry
8
+
9
+ include Equalizer.new(:guard, :entries)
10
+ include Enumerable
11
+
12
+ # Coerce +name+ into a Symbol
13
+ #
14
+ # @param [#to_sym] name
15
+ # the name to coerce
16
+ #
17
+ # @return [Symbol]
18
+ #
19
+ # @api private
20
+ def self.coerce_name(name)
21
+ name.to_sym
22
+ end
23
+
24
+ # The guard responsible for rejecting invalid entries
25
+ #
26
+ # @return [Guard]
27
+ #
28
+ # @api private
29
+ attr_reader :guard
30
+ protected :guard
31
+
32
+ # The entries this registry stores
33
+ #
34
+ # @return [Hash<Symbol, Object>]
35
+ #
36
+ # @api private
37
+ attr_reader :entries
38
+ protected :entries
39
+
40
+ # Initialize a new instance
41
+ #
42
+ # @param [Guard] guard
43
+ # the guard to use for rejecting invalid entries
44
+ #
45
+ # @param [Hash<Symbol, Object>] entires
46
+ # the entries this registry stores
47
+ #
48
+ # @return [undefined]
49
+ #
50
+ # @api private
51
+ def initialize(guard, entries = EMPTY_HASH)
52
+ @guard, @entries = guard, entries.dup
53
+ end
54
+
55
+ # Iterate over all entries
56
+ #
57
+ # @param [Proc] block
58
+ # the block passed to #{entries}.each
59
+ #
60
+ # @yield [name, object]
61
+ #
62
+ # @yieldparam [Symbol] name
63
+ # the name of the current entry
64
+ #
65
+ # @yieldparam [Object] object
66
+ # the object registered by name
67
+ #
68
+ # @return [self]
69
+ #
70
+ # @api private
71
+ def each(&block)
72
+ return to_enum unless block
73
+ entries.each(&block)
74
+ self
75
+ end
76
+
77
+ # Return a new instance with +other+ merged in
78
+ #
79
+ # @param [Registry] other
80
+ # the registry to merge
81
+ #
82
+ # @raise [AlreadyRegisteredError]
83
+ # if any object in +other+ is already registered by the same
84
+ # name in +self+
85
+ #
86
+ # @return [Registry]
87
+ # the new, merged instance
88
+ #
89
+ # @api private
90
+ def merge(other)
91
+ other.each_with_object(new) { |(name, object), merged|
92
+ merged[name] = object
93
+ }
94
+ end
95
+
96
+ # Register +object+ by +name+
97
+ #
98
+ # @param [#to_sym] name
99
+ # the name to register object with
100
+ #
101
+ # @param [Object] object
102
+ # the object to register by +name+
103
+ #
104
+ # @raise [AlreadyRegisteredError]
105
+ # if +object+ is already registered by the same +name+
106
+ #
107
+ # @raise [ReservedNameError]
108
+ # if +object+ should be registered using a reserved +name+
109
+ #
110
+ # @return [Object]
111
+ # the registered object
112
+ #
113
+ # @api private
114
+ def []=(name, object)
115
+ coerced_name = coerce_name(name)
116
+ guard.call(coerced_name, entries)
117
+ entries[coerced_name] = object
118
+ end
119
+
120
+ # Test wether an object is registered by +name+
121
+ #
122
+ # @param [#to_sym] name
123
+ # the name to test
124
+ #
125
+ # @return [Boolean]
126
+ # true if an object is registered, false otherwise
127
+ #
128
+ # @api private
129
+ def include?(name)
130
+ entries.include?(coerce_name(name))
131
+ end
132
+
133
+ # Return the object registered by +name+ or the value returned from +block+
134
+ #
135
+ # @param [#to_sym] name
136
+ # the name of the object to fetch
137
+ #
138
+ # @param [Proc] block
139
+ # the block to invoke if no object is registered by +name+
140
+ #
141
+ # @return [Object]
142
+ #
143
+ # @api private
144
+ def fetch(name, &block)
145
+ entries.fetch(coerce_name(name), &block)
146
+ end
147
+
148
+ # Return all names by which objects are registered
149
+ #
150
+ # @return [Array<Symbol>]
151
+ #
152
+ # @api private
153
+ def keys
154
+ entries.keys
155
+ end
156
+
157
+ private
158
+
159
+ # Coerce +name+ into a Symbol
160
+ #
161
+ # @param [#to_sym] name
162
+ # the name to coerce
163
+ #
164
+ # @return [Symbol]
165
+ #
166
+ # @api private
167
+ def coerce_name(name)
168
+ self.class.coerce_name(name)
169
+ end
170
+
171
+ # Return a new instance with {#guard} and {#entries}
172
+ #
173
+ # @return [Registry]
174
+ #
175
+ # @api private
176
+ def new
177
+ self.class.new(guard, entries)
178
+ end
179
+ end # class Registry
180
+ end # module DSL
181
+ end # module Substation
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Substation
2
4
 
3
5
  # The environment holding all registered {Chain} processors
@@ -8,69 +10,170 @@ module Substation
8
10
 
9
11
  # Build a new {Environment} instance
10
12
  #
13
+ # @param [Object] app_env
14
+ # the application environment
15
+ #
16
+ # @param [Dispatcher::Registry] actions
17
+ # a mutable action registry
18
+ #
11
19
  # @param [Proc] block
12
20
  # a block to be instance_eval'ed with {DSL}
13
21
  #
14
22
  # @return [Environment]
15
23
  #
16
24
  # @api private
17
- def self.build(&block)
18
- new(DSL.registry(&block))
25
+ def self.build(app_env, actions = Dispatcher.new_registry, &block)
26
+ new(app_env, actions, chain_dsl(&block))
27
+ end
28
+
29
+ # Build a new {Chain::DSL} instance
30
+ #
31
+ # @param [Proc] block
32
+ # a block to be instance_eval'ed in {DSL}
33
+ #
34
+ # @return {Chain::DSL}
35
+ #
36
+ # @api private
37
+ def self.chain_dsl(&block)
38
+ Chain::DSL.build(DSL.registry(&block))
19
39
  end
20
40
 
41
+ private_class_method :chain_dsl
42
+
43
+ # The application environment
44
+ #
45
+ # @return [Object]
46
+ #
47
+ # @api private
48
+ attr_reader :app_env
49
+
50
+ # The mutable action registry
51
+ #
52
+ # @return [Dispatcher::Registry]
53
+ #
54
+ # @api private
55
+ attr_reader :actions
56
+
57
+ # The registry used by this {Environment}
58
+ #
59
+ # @return [Hash<Symbol, Processor::Builder>]
60
+ #
61
+ # @api private
62
+ attr_reader :registry
63
+ protected :registry
64
+
21
65
  # Initialize a new instance
22
66
  #
23
- # @param [Hash<Symbol, #call>] registry
24
- # the registry of processors
67
+ # @param [Chain::DSL] chain_dsl
68
+ # the chain dsl tailored for the environment
25
69
  #
26
70
  # @return [undefined]
27
71
  #
28
72
  # @api private
29
- def initialize(registry)
30
- @registry = registry
31
- @chain_dsl = Chain::DSL::Builder.call(@registry)
73
+ def initialize(app_env, actions, chain_dsl)
74
+ @app_env = app_env
75
+ @actions = actions
76
+ @chain_dsl = chain_dsl
77
+ @registry = chain_dsl.registry
78
+ end
79
+
80
+ # Inherit a new instance from self, merging the {Chain::DSL}
81
+ #
82
+ # @param [Dispatcher::Registry] actions
83
+ # the mutable action registry
84
+ #
85
+ # @param [Proc] block
86
+ # a block to instance_eval inside a {DSL} instance
87
+ #
88
+ # @return [Environment]
89
+ #
90
+ # @api private
91
+ def inherit(app_env = app_env, actions = Dispatcher.new_registry, &block)
92
+ self.class.new(app_env, actions, merged_chain_dsl(&block))
32
93
  end
33
94
 
34
95
  # Build a new {Chain} instance
35
96
  #
97
+ # @param [#to_sym] name
98
+ # the new chain's name
99
+ #
36
100
  # @param [Chain] other
37
101
  # the optional chain to build on top of
38
102
  #
103
+ # @param [Chain] exception_chain
104
+ # the chain to invoke in case of an uncaught exceptions in handlers
105
+ #
39
106
  # @param [Proc] block
40
107
  # a block to be instance_eval'ed in {Chain::DSL}
41
108
  #
42
109
  # @return [Chain]
43
110
  #
44
111
  # @api private
45
- def chain(other = Chain::EMPTY, &block)
46
- Chain.new(processors(other, &block))
112
+ def chain(name = nil, other = Chain::EMPTY, exception_chain = Chain::EMPTY, &block)
113
+ @chain_dsl.build(name, other, exception_chain, &block)
47
114
  end
48
115
 
49
- protected
50
-
51
- # The registry used by this {Environment}
116
+ # Register a new chain under the given +name+
117
+ #
118
+ # @param [#to_sym] name
119
+ # the new chain's name
52
120
  #
53
- # @return [Hash<Symbol, #call>]
121
+ # @param [Chain] other
122
+ # the chain to build on top of
123
+ #
124
+ # @param [Chain] exception_chain
125
+ # the chain to invoke in case of uncaught exceptions in handlers
126
+ #
127
+ # @return [Chain]
128
+ # the registered chain
54
129
  #
55
130
  # @api private
56
- attr_reader :registry
131
+ def register(name, other = Chain::EMPTY, exception_chain = Chain::EMPTY, &block)
132
+ actions[name] = chain(name, other, exception_chain, &block)
133
+ self
134
+ end
57
135
 
58
- private
136
+ # Return the chain identified by +name+ or raise an error
137
+ #
138
+ # @param [name]
139
+ # the name of the chain to retrieve
140
+ #
141
+ # @return [Chain]
142
+ #
143
+ # @raise [UnknownActionError]
144
+ # if no chain is registered under +name+
145
+ #
146
+ # @api private
147
+ def [](name)
148
+ actions.fetch(name)
149
+ end
59
150
 
60
- # The processors collected via the chain dsl instance
151
+ # Build a new {Dispatcher} instance
61
152
  #
62
- # @param [Chain] other
63
- # another chain to build upon
153
+ # @see Dispatcher.new
64
154
  #
65
- # @param [Proc] block
66
- # the block to pass to {Chain::DSL#processors}
155
+ # @param [Object] env
156
+ # the application environment
67
157
  #
68
- # @return [Hash<Symbol, #call>]
158
+ # @return [Dispatcher]
69
159
  #
70
160
  # @api private
71
- def processors(other, &block)
72
- @chain_dsl.processors(self, other, &block)
161
+ def dispatcher
162
+ Dispatcher.new(actions, app_env)
73
163
  end
74
164
 
165
+ private
166
+
167
+ # Return a new {Chain::DSL} by merging in +other.registry+
168
+ #
169
+ # @param [Environment] other
170
+ # the other environment providing the registry to merge
171
+ #
172
+ # @return [Chain::DSL]
173
+ #
174
+ # @api private
175
+ def merged_chain_dsl(&block)
176
+ Chain::DSL.build(registry.merge(DSL.registry(&block)))
177
+ end
75
178
  end # class Environment
76
179
  end # module Substation
@@ -1,27 +1,39 @@
1
+ # encoding: utf-8
2
+
1
3
  module Substation
2
4
  class Environment
3
5
 
4
- # The DSL class used to define register processors
6
+ # The DSL class used to register processor builders
5
7
  class DSL
6
8
 
7
- # The registry of processors
9
+ # Rejects already registered and reserved names
10
+ GUARD = Substation::DSL::Guard.new(Chain::DSL::BASE_METHODS)
11
+
12
+ # The registry of processor builders
8
13
  #
9
- # @return [Hash<Symbol, #call>]
14
+ # @return [Hash<Symbol, Processor::Builder>]
10
15
  #
11
16
  # @api private
12
17
  attr_reader :registry
13
18
 
19
+ # The guard to use for rejecting invalid names
20
+ #
21
+ # @return [Guard]
22
+ #
23
+ # @api private
24
+ attr_reader :guard
25
+ private :guard
14
26
 
15
- # The registry of processors
27
+ # The registry of processor builders
16
28
  #
17
29
  # @param [Proc] block
18
30
  # a block to be instance_eval'ed
19
31
  #
20
- # @return [Hash<Symbol, #call>]
32
+ # @return [Hash<Symbol, Processor::Builder>]
21
33
  #
22
34
  # @api private
23
- def self.registry(&block)
24
- new(&block).registry
35
+ def self.registry(guard = GUARD, &block)
36
+ new(Substation::DSL::Registry.new(guard), &block).registry
25
37
  end
26
38
 
27
39
  # Initialize a new instance
@@ -32,12 +44,12 @@ module Substation
32
44
  # @return [undefined]
33
45
  #
34
46
  # @api private
35
- def initialize(&block)
36
- @registry = {}
47
+ def initialize(registry, &block)
48
+ @registry = registry
37
49
  instance_eval(&block) if block
38
50
  end
39
51
 
40
- # Register a new +processor+ using the given +name+
52
+ # Register a new +processor+ using the given +name+ and +executor+
41
53
  #
42
54
  # @param [#to_sym] name
43
55
  # the name to register the +processor+ for
@@ -45,11 +57,18 @@ module Substation
45
57
  # @param [#call] processor
46
58
  # the processor to register for +name+
47
59
  #
60
+ # @param [Processor::Executor] executor
61
+ # the executor for +processor+
62
+ #
48
63
  # @return [self]
49
64
  #
50
65
  # @api private
51
- def register(name, processor)
52
- @registry[name] = processor
66
+ def register(name, processor, executor = Processor::Executor::NULL)
67
+ coerced_name = name.to_sym
68
+
69
+ registry[coerced_name] =
70
+ Processor::Builder.new(coerced_name, processor, executor)
71
+
53
72
  self
54
73
  end
55
74