From 9a93844aba44319d3c8487a554124beb00ccc267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 30 May 2010 15:53:14 +0200 Subject: Add :only and :except to controllers MiddlewareStack. This allows you to do the following: class PostsController < ApplicationController use AutheMiddleware, :except => [:index, :show] end --- actionpack/lib/action_dispatch/middleware/stack.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_dispatch/middleware') diff --git a/actionpack/lib/action_dispatch/middleware/stack.rb b/actionpack/lib/action_dispatch/middleware/stack.rb index 0e5ab507df..e3180dba77 100644 --- a/actionpack/lib/action_dispatch/middleware/stack.rb +++ b/actionpack/lib/action_dispatch/middleware/stack.rb @@ -55,7 +55,7 @@ module ActionDispatch def insert(index, *args, &block) index = self.index(index) unless index.is_a?(Integer) - middleware = Middleware.new(*args, &block) + middleware = self.class::Middleware.new(*args, &block) super(index, middleware) end @@ -73,7 +73,7 @@ module ActionDispatch end def use(*args, &block) - middleware = Middleware.new(*args, &block) + middleware = self.class::Middleware.new(*args, &block) push(middleware) end @@ -82,8 +82,8 @@ module ActionDispatch "was removed from the middleware stack", caller end - def build(app = nil, &blk) - app ||= blk + def build(app = nil, &block) + app ||= block raise "MiddlewareStack#build requires an app" unless app reverse.inject(app) { |a, e| e.build(a) } end -- cgit v1.2.3