Class: ActionDispatch::MiddlewareStack
- Inherits:
-
Array
show all
- Defined in:
- actionpack/lib/action_dispatch/middleware/stack.rb
Defined Under Namespace
Classes: Middleware
Instance Method Summary
(collapse)
Methods inherited from Array
#as_json, #encode_json, #extract_options!, #fifth, #forty_two, #fourth, #from, #in_groups, #in_groups_of, #sample, #second, #split, #third, #to, #to_formatted_s, #to_param, #to_query, #to_sentence, #to_xml, #uniq_by, #uniq_by!, wrap
Constructor Details
- (MiddlewareStack) initialize(*args) {|_self| ... }
Also known as:
array_initialize
A new instance of MiddlewareStack
47
48
49
50
|
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 47
def initialize(*args)
array_initialize(*args)
yield(self) if block_given?
end
|
Instance Method Details
- (Object) build(app = nil, &block)
75
76
77
78
79
|
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 75
def build(app = nil, &block)
app ||= block
raise "MiddlewareStack#build requires an app" unless app
reverse.inject(app) { |a, e| e.build(a) }
end
|
- (Object) insert(index, *args, &block)
Also known as:
insert_before
52
53
54
55
56
|
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 52
def insert(index, *args, &block)
index = assert_index(index, :before)
middleware = self.class::Middleware.new(*args, &block)
super(index, middleware)
end
|
- (Object) insert_after(index, *args, &block)
60
61
62
63
|
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 60
def insert_after(index, *args, &block)
index = assert_index(index, :after)
insert(index + 1, *args, &block)
end
|
- (Object) swap(target, *args, &block)
65
66
67
68
|
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 65
def swap(target, *args, &block)
insert_before(target, *args, &block)
delete(target)
end
|
- (Object) use(*args, &block)
70
71
72
73
|
# File 'actionpack/lib/action_dispatch/middleware/stack.rb', line 70
def use(*args, &block)
middleware = self.class::Middleware.new(*args, &block)
push(middleware)
end
|