use Proc.new to automatically do parameter checking for us

This commit is contained in:
Aaron Patterson 2014-05-23 11:20:05 -07:00
parent 7c26f0141c
commit 93ae747c59
1 changed files with 1 additions and 3 deletions

View File

@ -30,10 +30,8 @@ module ActionController
end
end
def build(action, app=nil, &block)
app ||= block
def build(action, app = Proc.new)
action = action.to_s
raise "MiddlewareStack#build requires an app" unless app
middlewares.reverse.inject(app) do |a, middleware|
middleware.valid?(action) ? middleware.build(a) : a