class Catalyst::RunStack

Public Class Methods

new(&block) click to toggle source

Start a RunStack with a block

# File lib/catalyst.rb, line 14
def initialize(&block)
  instance_eval(&block) if block_given?
end

Public Instance Methods

call(env={}) click to toggle source

Start off the middleware

# File lib/catalyst.rb, line 41
def call(env={})
  to_app.call(env)
end
run(k, *args, &block)
Alias for: use
stack() click to toggle source

middleware stack

# File lib/catalyst.rb, line 19
def stack
  @stack ||= []
end
to_app() click to toggle source

Turn this RunStack to a Runner

# File lib/catalyst.rb, line 36
def to_app
  Runner.new(stack)
end
use(k, *args, &block) click to toggle source

Use 'middleware'

# 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
Also aliased as: run