Class: Roda::RodaPlugins::MiddlewareStack::StackPosition
- Inherits:
-
Object
- Object
- Roda::RodaPlugins::MiddlewareStack::StackPosition
- Defined in:
- lib/roda/plugins/middleware_stack.rb
Overview
Represents a specific position in the application’s middleware stack where new middleware can be inserted.
Instance Method Summary collapse
-
#initialize(app, middleware, position) ⇒ StackPosition
constructor
A new instance of StackPosition.
-
#use(*args, &block) ⇒ Object
Insert a new middleware into the current position in the middleware stack.
Constructor Details
#initialize(app, middleware, position) ⇒ StackPosition
Returns a new instance of StackPosition.
22 23 24 25 26 |
# File 'lib/roda/plugins/middleware_stack.rb', line 22 def initialize(app, middleware, position) @app = app @middleware = middleware @position = position end |
Instance Method Details
#use(*args, &block) ⇒ Object
Insert a new middleware into the current position in the middleware stack. Increments the position so that calling this multiple times adds later middleware after earlier middleware, similar to how Roda.use
works.
31 32 33 34 35 36 |
# File 'lib/roda/plugins/middleware_stack.rb', line 31 def use(*args, &block) @middleware.insert(@position, [args, block]) @app.send(:build_rack_app) @position += 1 nil end |