Class: Substation::Dispatcher
- Inherits:
-
Object
- Object
- Substation::Dispatcher
- Includes:
- Adamantium::Flat
- Defined in:
- lib/substation/dispatcher.rb
Overview
Encapsulates all registered actions and their observers
The only protocol actions must support is #call(request). Actions are intended to be classes that handle one specific application use case.
Constant Summary collapse
- GUARD =
DSL::Guard.new(EMPTY_ARRAY)
Class Method Summary collapse
-
.new_registry ⇒ DSL::Registry
private
Return a new registry instance suitable for Dispatcher.
Instance Method Summary collapse
-
#call(name, input) ⇒ Response
Invoke the action identified by
name
. -
#include?(name) ⇒ Boolean
private
Test wether a chain with the given
name
is registered.
Class Method Details
.new_registry ⇒ DSL::Registry
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.
Return a new registry instance suitable for Substation::Dispatcher
22 23 24 |
# File 'lib/substation/dispatcher.rb', line 22 def self.new_registry DSL::Registry.new(GUARD) end |
Instance Method Details
#call(name, input) ⇒ Response
Invoke the action identified by name
66 67 68 |
# File 'lib/substation/dispatcher.rb', line 66 def call(name, input) fetch(name).call(Request.new(name, env, input)) end |
#include?(name) ⇒ Boolean
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.
Test wether a chain with the given name
is registered
78 79 80 |
# File 'lib/substation/dispatcher.rb', line 78 def include?(name) actions.include?(name) end |