Class: ActionDispatch::MiddlewareStack
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
ActionController::MiddlewareStack
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
::Enumerable
|
|
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/middleware/stack.rb |
Class Method Summary
- .new(*args) {|_self| ... } ⇒ MiddlewareStack constructor
Instance Attribute Summary
- #middlewares rw
::Enumerable
- Included
#many? | Returns |
Instance Method Summary
- #[](i)
- #build(app = nil, &block)
- #delete(target)
- #each
- #initialize_copy(other)
- #insert(index, klass, *args, &block) (also: #insert_before)
- #insert_after(index, *args, &block)
-
#insert_before(index, klass, *args, &block)
Alias for #insert.
- #last
- #size
- #swap(target, *args, &block)
- #unshift(klass, *args, &block)
- #use(klass, *args, &block)
::Enumerable
- Included
Constructor Details
.new(*args) {|_self| ... } ⇒ MiddlewareStack
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 45
def initialize(*args) @middlewares = [] yield(self) if block_given? end
Instance Attribute Details
#middlewares (rw)
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 43
attr_accessor :middlewares
Instance Method Details
#[](i)
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 62
def [](i) middlewares[i] end
#build(app = nil, &block)
[ GitHub ]# 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
#delete(target)
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 92
def delete(target) middlewares.delete_if { |m| m.klass == target } end
#each
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 50
def each @middlewares.each { |x| yield x } end
#initialize_copy(other)
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 70
def initialize_copy(other) self.middlewares = other.middlewares.dup end
#insert(index, klass, *args, &block) Also known as: #insert_before
[ GitHub ]# 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
#insert_after(index, *args, &block)
[ GitHub ]# 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
#insert_before(index, klass, *args, &block)
Alias for #insert.
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 79
alias_method :insert_before, :insert
#last
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 58
def last middlewares.last end
#size
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 54
def size middlewares.size end
#swap(target, *args, &block)
[ GitHub ]# 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
#unshift(klass, *args, &block)
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 66
def unshift(klass, *args, &block) middlewares.unshift(build_middleware(klass, args, block)) end
#use(klass, *args, &block)
[ GitHub ]# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 96
def use(klass, *args, &block) middlewares.push(build_middleware(klass, args, block)) end