Namespace
Class
Methods
- []
- build
- delete
- each
- initialize_copy
- insert
- insert_after
- insert_before
- last
- new
- size
- swap
- unshift
- use
Included Modules
Attributes
[RW] | middlewares |
Class Public methods
new(*args)
📝 Source code
# File actionpack/lib/action_dispatch/middleware/stack.rb, line 45
def initialize(*args)
@middlewares = []
yield(self) if block_given?
end
🔎 See on GitHub
Instance Public methods
[](i)
📝 Source code
# File actionpack/lib/action_dispatch/middleware/stack.rb, line 62
def [](i)
middlewares[i]
end
🔎 See on GitHub
build(app = nil, &block)
📝 Source code
# File actionpack/lib/action_dispatch/middleware/stack.rb, line 100
def build(app = nil, &block)
middlewares.freeze.reverse.inject(app || block) { |a, e| e.build(a) }
end
🔎 See on GitHub
delete(target)
📝 Source code
# File actionpack/lib/action_dispatch/middleware/stack.rb, line 92
def delete(target)
middlewares.delete_if { |m| m.klass == target }
end
🔎 See on GitHub
each()
📝 Source code
# File actionpack/lib/action_dispatch/middleware/stack.rb, line 50
def each
@middlewares.each { |x| yield x }
end
🔎 See on GitHub
initialize_copy(other)
📝 Source code
# File actionpack/lib/action_dispatch/middleware/stack.rb, line 70
def initialize_copy(other)
self.middlewares = other.middlewares.dup
end
🔎 See on GitHub
insert(index, klass, *args, &block)
Also aliased as: insert_before
📝 Source code
# File actionpack/lib/action_dispatch/middleware/stack.rb, line 74
def insert(index, klass, *args, &block)
index = assert_index(index, :before)
middlewares.insert(index, build_middleware(klass, args, block))
end
🔎 See on GitHub
insert_after(index, *args, &block)
📝 Source code
# File actionpack/lib/action_dispatch/middleware/stack.rb, line 81
def insert_after(index, *args, &block)
index = assert_index(index, :after)
insert(index + 1, *args, &block)
end
🔎 See on GitHub
last()
📝 Source code
# File actionpack/lib/action_dispatch/middleware/stack.rb, line 58
def last
middlewares.last
end
🔎 See on GitHub
size()
📝 Source code
# File actionpack/lib/action_dispatch/middleware/stack.rb, line 54
def size
middlewares.size
end
🔎 See on GitHub
swap(target, *args, &block)
📝 Source code
# File actionpack/lib/action_dispatch/middleware/stack.rb, line 86
def swap(target, *args, &block)
index = assert_index(target, :before)
insert(index, *args, &block)
middlewares.delete_at(index + 1)
end
🔎 See on GitHub
unshift(klass, *args, &block)
📝 Source code
# File actionpack/lib/action_dispatch/middleware/stack.rb, line 66
def unshift(klass, *args, &block)
middlewares.unshift(build_middleware(klass, args, block))
end
🔎 See on GitHub
use(klass, *args, &block)
📝 Source code
# File actionpack/lib/action_dispatch/middleware/stack.rb, line 96
def use(klass, *args, &block)
middlewares.push(build_middleware(klass, args, block))
end
🔎 See on GitHub