Class: ActionDispatch::MiddlewareStack
- Inherits:
-
Array
- Object
- Array
- ActionDispatch::MiddlewareStack
show all
- Defined in:
- lib/action_dispatch/middleware/stack.rb
Defined Under Namespace
Classes: Middleware
Instance Method Summary
collapse
Constructor Details
Returns a new instance of MiddlewareStack.
43
44
45
46
|
# File 'lib/action_dispatch/middleware/stack.rb', line 43
def initialize(*args, &block)
super(*args)
block.call(self) if block_given?
end
|
Instance Method Details
#active ⇒ Object
71
72
73
74
|
# 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) ⇒ Object
76
77
78
79
80
|
# 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) ⇒ Object
Also known as:
insert_before
48
49
50
51
52
|
# 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
|
#insert_after(index, *args, &block) ⇒ Object
56
57
58
59
|
# 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
|
#swap(target, *args, &block) ⇒ Object
61
62
63
64
|
# 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) ⇒ Object
66
67
68
69
|
# File 'lib/action_dispatch/middleware/stack.rb', line 66
def use(*args, &block)
middleware = self.class::Middleware.new(*args, &block)
push(middleware)
end
|