From e4f9a0b92531fa68cc2cdbd52b66904515fcd486 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 7 Aug 2015 11:20:28 -0700 Subject: use Proc.new to reduce some conditionals Proc.new will pick up the passed in block, but since it's a default param, it won't get evaluated unless someone doesn't pass in an app. It will raise an exception if no block is provided. --- actionpack/lib/action_dispatch/middleware/stack.rb | 4 +--- 1 file changed, 1 insertion(+), 3 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 bbf734f103..87e627319e 100644 --- a/actionpack/lib/action_dispatch/middleware/stack.rb +++ b/actionpack/lib/action_dispatch/middleware/stack.rb @@ -112,9 +112,7 @@ module ActionDispatch middlewares.push(middleware) end - def build(app = nil, &block) - app ||= block - raise "MiddlewareStack#build requires an app" unless app + def build(app = Proc.new) middlewares.freeze.reverse.inject(app) { |a, e| e.build(a) } end -- cgit v1.2.3