class ActionDispatch::MiddlewareStack

Public Instance Methods

active() click to toggle source
# File lib/action_dispatch/middleware/stack.rb, line 71
def active
  ActiveSupport::Deprecation.warn "All middlewares in the chain are active since the laziness " <<
    "was removed from the middleware stack", caller
end
build(app = nil, &block) click to toggle source
# File lib/action_dispatch/middleware/stack.rb, line 76
def build(app = nil, &block)
  app ||= block
  raise "MiddlewareStack#build requires an app" unless app
  reverse.inject(app) { |a, e| e.build(a) }
end
insert(index, *args, &block) click to toggle source
# File lib/action_dispatch/middleware/stack.rb, line 48
def insert(index, *args, &block)
  index = assert_index(index, :before)
  middleware = self.class::Middleware.new(*args, &block)
  super(index, middleware)
end
Also aliased as: insert_before
insert_after(index, *args, &block) click to toggle source
# File lib/action_dispatch/middleware/stack.rb, line 56
def insert_after(index, *args, &block)
  index = assert_index(index, :after)
  insert(index + 1, *args, &block)
end
insert_before(index, *args, &block) click to toggle source
Alias for: insert
swap(target, *args, &block) click to toggle source
# File lib/action_dispatch/middleware/stack.rb, line 61
def swap(target, *args, &block)
  insert_before(target, *args, &block)
  delete(target)
end
use(*args, &block) click to toggle source
# File lib/action_dispatch/middleware/stack.rb, line 66
def use(*args, &block)
  middleware = self.class::Middleware.new(*args, &block)
  push(middleware)
end

Protected Instance Methods

assert_index(index, where) click to toggle source
# File lib/action_dispatch/middleware/stack.rb, line 84
def assert_index(index, where)
  i = index.is_a?(Integer) ? index : self.index(index)
  raise "No such middleware to insert #{where}: #{index.inspect}" unless i
  i
end

Public Class Methods

new(*args, &block) click to toggle source
# File lib/action_dispatch/middleware/stack.rb, line 43
def initialize(*args, &block)
  super(*args)
  block.call(self) if block_given?
end