Class: ConvenientService::Dependencies::Extractions::RubyMiddleware::Middleware::Runner
- Inherits:
-
Object
- Object
- ConvenientService::Dependencies::Extractions::RubyMiddleware::Middleware::Runner
- Defined in:
- lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/runner.rb
Overview
This is a basic runner for middleware stacks. This runner does the default expected behavior of running the middleware stacks in order, then reversing the order.
Constant Summary collapse
- EMPTY_MIDDLEWARE =
A middleware which does nothing
->(env) { env }
Instance Method Summary collapse
-
#call(env) ⇒ Object
Run the middleware stack with the given state bag.
-
#initialize(stack) ⇒ Runner
constructor
Build a new middleware runner with the given middleware stack.
Constructor Details
#initialize(stack) ⇒ Runner
Build a new middleware runner with the given middleware stack.
Note: This class usually doesn't need to be used directly. Instead, take a look at using the Builder class, which is a much friendlier way to build up a middleware stack.
31 32 33 34 35 |
# File 'lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/runner.rb', line 31 def initialize(stack) # We need to take the stack of middleware and initialize them # all so they call the proper next middleware. @kickoff = build_call_chain(stack) end |
Instance Method Details
#call(env) ⇒ Object
Run the middleware stack with the given state bag.
41 42 43 44 45 46 |
# File 'lib/convenient_service/dependencies/extractions/ruby_middleware/middleware/runner.rb', line 41 def call(env) # We just call the kickoff middleware, which is responsible # for properly calling the next middleware, and so on and so # forth. @kickoff.call(env) end |