diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-07 11:20:28 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-07 15:37:31 -0700 |
commit | e4f9a0b92531fa68cc2cdbd52b66904515fcd486 (patch) | |
tree | 9272769c217e252d3b1aae61a36d48d052895af6 /actionpack/lib/action_dispatch/middleware | |
parent | 4485351501d39280102ea1b8db270a5a27ed7b63 (diff) | |
download | rails-e4f9a0b92531fa68cc2cdbd52b66904515fcd486.tar.gz rails-e4f9a0b92531fa68cc2cdbd52b66904515fcd486.tar.bz2 rails-e4f9a0b92531fa68cc2cdbd52b66904515fcd486.zip |
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.
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/stack.rb | 4 |
1 files changed, 1 insertions, 3 deletions
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 |