Class: Substation::Environment
- Inherits:
-
Object
- Object
- Substation::Environment
- Includes:
- Adamantium::Flat
- Defined in:
- lib/substation/environment.rb,
lib/substation/environment/dsl.rb
Overview
The environment holding all registered Chain processors
Defined Under Namespace
Classes: DSL
Instance Attribute Summary collapse
-
#actions ⇒ Dispatcher::Registry
readonly
private
The mutable action registry.
-
#app_env ⇒ Object
readonly
private
The application environment.
Class Method Summary collapse
-
.build(app_env, actions = Dispatcher.new_registry, &block) ⇒ Environment
private
Build a new Environment instance.
Instance Method Summary collapse
-
#[](name) ⇒ Chain
private
Return the chain identified by
nameor raise an error. -
#chain(name = nil, other = Chain::EMPTY, exception_chain = Chain::EMPTY, &block) ⇒ Chain
private
Build a new Chain instance.
-
#dispatcher ⇒ Dispatcher
private
Build a new Dispatcher instance.
-
#inherit(app_env = app_env, actions = Dispatcher.new_registry, &block) ⇒ Environment
private
Inherit a new instance from self, merging the Chain::DSL.
-
#initialize(app_env, actions, chain_dsl) ⇒ undefined
constructor
private
Initialize a new instance.
-
#register(name, other = Chain::EMPTY, exception_chain = Chain::EMPTY, &block) ⇒ Chain
private
Register a new chain under the given
name.
Constructor Details
#initialize(app_env, actions, chain_dsl) ⇒ 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
73 74 75 76 77 78 |
# File 'lib/substation/environment.rb', line 73 def initialize(app_env, actions, chain_dsl) @app_env = app_env @actions = actions @chain_dsl = chain_dsl @registry = chain_dsl.registry end |
Instance Attribute Details
#actions ⇒ Dispatcher::Registry (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 mutable action registry
55 56 57 |
# File 'lib/substation/environment.rb', line 55 def actions @actions end |
#app_env ⇒ Object (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 application environment
48 49 50 |
# File 'lib/substation/environment.rb', line 48 def app_env @app_env end |
Class Method Details
.build(app_env, actions = Dispatcher.new_registry, &block) ⇒ Environment
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.
Build a new Substation::Environment instance
25 26 27 |
# File 'lib/substation/environment.rb', line 25 def self.build(app_env, actions = Dispatcher.new_registry, &block) new(app_env, actions, chain_dsl(&block)) end |
Instance Method Details
#[](name) ⇒ Chain
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 the chain identified by name or raise an error
147 148 149 |
# File 'lib/substation/environment.rb', line 147 def [](name) actions.fetch(name) end |
#chain(name = nil, other = Chain::EMPTY, exception_chain = Chain::EMPTY, &block) ⇒ Chain
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.
Build a new Chain instance
112 113 114 |
# File 'lib/substation/environment.rb', line 112 def chain(name = nil, other = Chain::EMPTY, exception_chain = Chain::EMPTY, &block) @chain_dsl.build(name, other, exception_chain, &block) end |
#dispatcher ⇒ Dispatcher
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.
Build a new Dispatcher instance
161 162 163 |
# File 'lib/substation/environment.rb', line 161 def dispatcher Dispatcher.new(actions, app_env) end |
#inherit(app_env = app_env, actions = Dispatcher.new_registry, &block) ⇒ Environment
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.
Inherit a new instance from self, merging the Chain::DSL
91 92 93 |
# File 'lib/substation/environment.rb', line 91 def inherit(app_env = app_env, actions = Dispatcher.new_registry, &block) self.class.new(app_env, actions, merged_chain_dsl(&block)) end |
#register(name, other = Chain::EMPTY, exception_chain = Chain::EMPTY, &block) ⇒ Chain
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 chain under the given name
131 132 133 134 |
# File 'lib/substation/environment.rb', line 131 def register(name, other = Chain::EMPTY, exception_chain = Chain::EMPTY, &block) actions[name] = chain(name, other, exception_chain, &block) self end |