Namespace
Methods
- #
-
- A
-
- B
-
- D
-
- E
-
- I
-
- L
-
- N
-
- S
-
- U
-
Included Modules
Attributes
Class Public methods
Source:
show
| on GitHub
def initialize(*args)
@middlewares = []
yield(self) if block_given?
end
Instance Public methods
Source:
show
| on GitHub
def build(app = nil, &block)
app ||= block
raise "MiddlewareStack#build requires an app" unless app
middlewares.reverse.inject(app) { |a, e| e.build(a) }
end
Source:
show
| on GitHub
def delete(target)
middlewares.delete target
end
Source:
show
| on GitHub
def each
@middlewares.each { |x| yield x }
end
Source:
show
| on GitHub
def initialize_copy(other)
self.middlewares = other.middlewares.dup
end
insert(index, *args, &block)
Source:
show
| on GitHub
def insert(index, *args, &block)
index = assert_index(index, :before)
middleware = self.class::Middleware.new(*args, &block)
middlewares.insert(index, middleware)
end
insert_after(index, *args, &block)
Source:
show
| on GitHub
def insert_after(index, *args, &block)
index = assert_index(index, :after)
insert(index + 1, *args, &block)
end
insert_before(index, *args, &block)
swap(target, *args, &block)
Source:
show
| on GitHub
def swap(target, *args, &block)
index = assert_index(target, :before)
insert(index, *args, &block)
middlewares.delete_at(index + 1)
end
Source:
show
| on GitHub
def use(*args, &block)
middleware = self.class::Middleware.new(*args, &block)
middlewares.push(middleware)
end
Instance Protected methods
assert_index(index, where)
Source:
show
| on GitHub
def assert_index(index, where)
i = index.is_a?(Integer) ? index : middlewares.index(index)
raise "No such middleware to insert #{where}: #{index.inspect}" unless i
i
end