Class: Catalyst::RunStack
- Inherits:
-
Object
- Object
- Catalyst::RunStack
- Defined in:
- lib/catalyst.rb
Instance Method Summary collapse
-
#call(env = {}) ⇒ Object
Start off the middleware.
-
#initialize(&block) ⇒ RunStack
constructor
Start a RunStack with a block.
-
#stack ⇒ Object
middleware stack.
-
#to_app ⇒ Object
Turn this RunStack to a Runner.
-
#use(k, *args, &block) ⇒ Object
(also: #run)
Use ‘middleware’.
Constructor Details
#initialize(&block) ⇒ RunStack
Start a RunStack with a block
14 15 16 |
# File 'lib/catalyst.rb', line 14 def initialize(&block) instance_eval(&block) if block_given? end |
Instance Method Details
#call(env = {}) ⇒ Object
Start off the middleware
41 42 43 |
# File 'lib/catalyst.rb', line 41 def call(env={}) to_app.call(env) end |
#stack ⇒ Object
middleware stack
19 20 21 |
# File 'lib/catalyst.rb', line 19 def stack @stack ||= [] end |
#to_app ⇒ Object
Turn this RunStack to a Runner
36 37 38 |
# File 'lib/catalyst.rb', line 36 def to_app Runner.new(stack) end |
#use(k, *args, &block) ⇒ Object Also known as: run
Use ‘middleware’
24 25 26 27 28 29 30 31 |
# File 'lib/catalyst.rb', line 24 def use(k, *args, &block) if k.is_a?(RunStack) stack.concat(k.stack) else stack << [k, args, block] end self end |