diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-25 16:25:52 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-08-25 16:25:52 -0700 |
commit | 67b2841fbeb6db33dd78a95dd61329a8a56fc7c0 (patch) | |
tree | 793aaafccf0b982df8766262b358cda0b8d6c092 /actionpack/lib/action_controller | |
parent | a26033b4a620059dff2779bdc77024f3123cc44f (diff) | |
download | rails-67b2841fbeb6db33dd78a95dd61329a8a56fc7c0.tar.gz rails-67b2841fbeb6db33dd78a95dd61329a8a56fc7c0.tar.bz2 rails-67b2841fbeb6db33dd78a95dd61329a8a56fc7c0.zip |
adding a direct dispatch method to controller classes
This saves a lambda and request allocation on each request.
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/metal.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb index d68fa16847..54980aa453 100644 --- a/actionpack/lib/action_controller/metal.rb +++ b/actionpack/lib/action_controller/metal.rb @@ -259,5 +259,15 @@ module ActionController lambda { |env| new.dispatch(name, ActionDispatch::Request.new(env)) } end end + + # Direct dispatch to the controller. Instantiates the controller, then + # executes the action named +name+. + def self.dispatch(name, req) + if middleware_stack.any? + middleware_stack.build(name) { |env| new.dispatch(name, req) }.call req.env + else + new.dispatch(name, req) + end + end end end |