aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/middleware_stack.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/middleware_stack.rb b/actionpack/lib/action_controller/middleware_stack.rb
index b94bf6ec4a..dbc2fda41e 100644
--- a/actionpack/lib/action_controller/middleware_stack.rb
+++ b/actionpack/lib/action_controller/middleware_stack.rb
@@ -75,17 +75,22 @@ module ActionController
block.call(self) if block_given?
end
- def insert(index, *objs)
+ def insert(index, *args, &block)
index = self.index(index) unless index.is_a?(Integer)
- objs = objs.map { |obj| Middleware.new(obj) }
- super(index, *objs)
+ middleware = Middleware.new(*args, &block)
+ super(index, middleware)
end
alias_method :insert_before, :insert
- def insert_after(index, *objs)
+ def insert_after(index, *args, &block)
index = self.index(index) unless index.is_a?(Integer)
- insert(index + 1, *objs)
+ insert(index + 1, *args, &block)
+ end
+
+ def swap(target, *args, &block)
+ insert_before(target, *args, &block)
+ delete(target)
end
def use(*args, &block)