Module: Substation

Defined in:
lib/substation.rb,
lib/substation/chain.rb,
lib/substation/request.rb,
lib/substation/version.rb,
lib/substation/response.rb,
lib/substation/chain/dsl.rb,
lib/substation/dsl/guard.rb,
lib/substation/processor.rb,
lib/substation/dispatcher.rb,
lib/substation/environment.rb,
lib/substation/dsl/registry.rb,
lib/substation/response/api.rb,
lib/substation/processor/nest.rb,
lib/substation/environment/dsl.rb,
lib/substation/chain/definition.rb,
lib/substation/chain/dsl/config.rb,
lib/substation/processor/config.rb,
lib/substation/response/failure.rb,
lib/substation/response/success.rb,
lib/substation/processor/builder.rb,
lib/substation/processor/wrapper.rb,
lib/substation/processor/executor.rb,
lib/substation/response/exception.rb,
lib/substation/processor/evaluator.rb,
lib/substation/processor/transformer.rb,
lib/substation/chain/dsl/module_builder.rb,
lib/substation/response/exception/output.rb,
lib/substation/processor/evaluator/result.rb,
lib/substation/processor/evaluator/handler.rb

Overview

Substation can be thought of as a domain level request router. It assumes that every usecase in your application has a name and is implemented in a dedicated class that will be referred to as an action in the context of substation. The only protocol such actions must support is ‘#call(request)`.

The contract for actions specifies that when invoked, actions can receive arbitrary input data which will be available in ‘request.input`. Additionally, `request.env` contains an arbitrary object that represents your application environment and will typically provide access to useful things like a logger or a storage engine abstraction.

The contract further specifies that every action must return an instance of either ‘Substation::Response::Success` or `Substation::Response::Failure`. Again, arbitrary data can be associated with any kind of response, and will be available in `response.data`. In addition to that, `response.success?` is available and will indicate wether invoking the action was successful or not.

‘Substation::Dispatcher` stores a mapping of action names to the actual objects implementing the action. Clients can use `Substation::Dispatcher#call(name, input, env)` to dispatch to any registered action. For example, a web application could map an http route to a specific action name and pass relevant http params on to the action.

Defined Under Namespace

Modules: DSL, Processor Classes: Chain, Dispatcher, Environment, Request, Response

Constant Summary collapse

Undefined =

Represent an undefined argument

Object.new.freeze
EMPTY_ARRAY =

An empty frozen array useful for (default) parameters

[].freeze
EMPTY_HASH =

An empty frozen hash useful for (default) parameters

{}.freeze
UnknownProcessor =

Error raised when trying to access an unknown processor

Class.new(StandardError)
UnknownActionError =

Raised when trying to dispatch to an unregistered action

Class.new(StandardError)
AlreadyRegisteredError =

Raised when an object is already registered under the a given name

Class.new(StandardError)
ReservedNameError =

Raised when a reserved method is being given

Class.new(StandardError)
DuplicateProcessorError =

Raised when a duplicate Processor should be registered within a Chain

Class.new(StandardError)
VERSION =

Gem version

'0.0.10'.freeze