diff options
author | fatkodima <fatkodima123@gmail.com> | 2018-01-05 18:24:39 +0200 |
---|---|---|
committer | fatkodima <fatkodima123@gmail.com> | 2018-01-22 15:57:25 +0200 |
commit | fbf4e9562db9ba73428b9b397361aa886bc2c8e8 (patch) | |
tree | ad10cf49e3e6528f79f43ef8ad56d71db1a5f22a | |
parent | 109505843ff74585c2c30e3b187bced56ff3a08a (diff) | |
download | rails-fbf4e9562db9ba73428b9b397361aa886bc2c8e8.tar.gz rails-fbf4e9562db9ba73428b9b397361aa886bc2c8e8.tar.bz2 rails-fbf4e9562db9ba73428b9b397361aa886bc2c8e8.zip |
Remove code duplication for `ActionController::Metal.action`
-rw-r--r-- | actionpack/lib/action_controller/metal.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb index 457884ea08..f875aa5e6b 100644 --- a/actionpack/lib/action_controller/metal.rb +++ b/actionpack/lib/action_controller/metal.rb @@ -230,18 +230,16 @@ module ActionController # Returns a Rack endpoint for the given action name. def self.action(name) + app = lambda { |env| + req = ActionDispatch::Request.new(env) + res = make_response! req + new.dispatch(name, req, res) + } + if middleware_stack.any? - middleware_stack.build(name) do |env| - req = ActionDispatch::Request.new(env) - res = make_response! req - new.dispatch(name, req, res) - end + middleware_stack.build(name, app) else - lambda { |env| - req = ActionDispatch::Request.new(env) - res = make_response! req - new.dispatch(name, req, res) - } + app end end |