提交 e4f9a0b9 编写于 作者: A Aaron Patterson

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.
上级 44853515
......@@ -112,9 +112,7 @@ def use(*args, &block)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册