aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorRich Healey <richard.healey@99designs.com>2012-05-18 16:41:52 +1000
committerRich Healey <richard.healey@99designs.com>2012-05-18 16:41:52 +1000
commit793205cccfb3addd8f6aca59d60655b55e4fc38e (patch)
treed77c2bc2e1fc912ebd17e708eb31072da2fc0947 /actionpack/lib
parentb23ac936a6ef980547666da002681a77d8340573 (diff)
downloadrails-793205cccfb3addd8f6aca59d60655b55e4fc38e.tar.gz
rails-793205cccfb3addd8f6aca59d60655b55e4fc38e.tar.bz2
rails-793205cccfb3addd8f6aca59d60655b55e4fc38e.zip
Add the #unshift method to the middleware stack
The docs suggest that the middleware stack is an Array, so I've added the unshift method to it. Originally I added some more Array methods, but it was agreed that they lacked usecases.
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_dispatch/middleware/stack.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/stack.rb b/actionpack/lib/action_dispatch/middleware/stack.rb
index 12bc438be3..bbf734f103 100644
--- a/actionpack/lib/action_dispatch/middleware/stack.rb
+++ b/actionpack/lib/action_dispatch/middleware/stack.rb
@@ -75,6 +75,11 @@ module ActionDispatch
middlewares[i]
end
+ def unshift(*args, &block)
+ middleware = self.class::Middleware.new(*args, &block)
+ middlewares.unshift(middleware)
+ end
+
def initialize_copy(other)
self.middlewares = other.middlewares.dup
end