Class: Toys::Middleware::Stack
- Inherits:
-
Object
- Object
- Toys::Middleware::Stack
- Defined in:
- core-docs/toys/middleware.rb
Overview
A stack of middleware specs, which can be applied in order to a tool.
A middleware stack is separated into three groups:
- #pre_specs, which are applied first.
- #default_specs, which are applied next. The default specs are set when the stack is created and are generally not modified.
- #post_specs, which are applied third.
When adding middleware to a stack, you should normally add them to the pre or post specs. By default, #add appends to the pre specs, inserting new middleware just before the defaults.
Use stack to create a middleware stack.
Defined in the toys-core gem
Instance Attribute Summary collapse
-
#default_specs ⇒ Array<Toys::Middleware:Spec>
readonly
The default set of middleware specs.
-
#post_specs ⇒ Array<Toys::Middleware:Spec>
readonly
The middleware specs that follow the default set.
-
#pre_specs ⇒ Array<Toys::Middleware:Spec>
readonly
The middleware specs that precede the default set.
Instance Method Summary collapse
-
#==(other) ⇒ boolean
(also: #eql?)
Equality check.
-
#add(middleware, *args, **kwargs, &block) ⇒ Object
Add a middleware spec to the stack, in the default location, which is at the end of pre_specs, right before the default_specs.
-
#build(middleware_lookup) ⇒ Array<Toys::Middleware>
Build the middleware in this stack.
-
#dup ⇒ Toys::Middleware::Stack
Duplicate this stack.
-
#hash ⇒ Integer
Return the hash code.
Instance Attribute Details
#default_specs ⇒ Array<Toys::Middleware:Spec> (readonly)
The default set of middleware specs.
249 250 251 |
# File 'core-docs/toys/middleware.rb', line 249 def default_specs @default_specs end |
#post_specs ⇒ Array<Toys::Middleware:Spec> (readonly)
The middleware specs that follow the default set.
255 256 257 |
# File 'core-docs/toys/middleware.rb', line 255 def post_specs @post_specs end |
#pre_specs ⇒ Array<Toys::Middleware:Spec> (readonly)
The middleware specs that precede the default set.
243 244 245 |
# File 'core-docs/toys/middleware.rb', line 243 def pre_specs @pre_specs end |
Instance Method Details
#==(other) ⇒ boolean Also known as: eql?
Equality check
294 295 296 |
# File 'core-docs/toys/middleware.rb', line 294 def ==(other) # Source available in the toys-core gem end |
#add(name, *args, **kwargs, &block) ⇒ Object #add(array) ⇒ Object #add(middleware_object) ⇒ Object
Add a middleware spec to the stack, in the default location, which is at the end of pre_specs, right before the default_specs. See Toys::Middleware.spec for a description of the arguments you can pass.
266 267 268 |
# File 'core-docs/toys/middleware.rb', line 266 def add(middleware, *args, **kwargs, &block) # Source available in the toys-core gem end |
#build(middleware_lookup) ⇒ Array<Toys::Middleware>
Build the middleware in this stack.
284 285 286 |
# File 'core-docs/toys/middleware.rb', line 284 def build(middleware_lookup) # Source available in the toys-core gem end |
#dup ⇒ Toys::Middleware::Stack
Duplicate this stack.
275 276 277 |
# File 'core-docs/toys/middleware.rb', line 275 def dup # Source available in the toys-core gem end |
#hash ⇒ Integer
Return the hash code
304 305 306 |
# File 'core-docs/toys/middleware.rb', line 304 def hash # Source available in the toys-core gem end |