diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-09-14 09:47:55 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-09-14 09:47:55 -0300 |
commit | 24260dc0c8338aef8e24407e00750fd72a0366ea (patch) | |
tree | 849b286decba65c1136947ef6f52235335df2383 /actionpack/lib/action_controller/metal.rb | |
parent | 0489f0c582d2ab70595296f058545b102466bebd (diff) | |
parent | 181cd109d9812d371e2d554a4846f0b2b25b1690 (diff) | |
download | rails-24260dc0c8338aef8e24407e00750fd72a0366ea.tar.gz rails-24260dc0c8338aef8e24407e00750fd72a0366ea.tar.bz2 rails-24260dc0c8338aef8e24407e00750fd72a0366ea.zip |
Merge commit 'rails/master'
Diffstat (limited to 'actionpack/lib/action_controller/metal.rb')
-rw-r--r-- | actionpack/lib/action_controller/metal.rb | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb index 51fbba3661..6aa4fe6019 100644 --- a/actionpack/lib/action_controller/metal.rb +++ b/actionpack/lib/action_controller/metal.rb @@ -79,6 +79,15 @@ module ActionController end class ActionEndpoint + @@endpoints = Hash.new {|h,k| h[k] = Hash.new {|h,k| h[k] = {} } } + + def self.for(controller, action, stack) + @@endpoints[controller][action][stack] ||= begin + endpoint = new(controller, action) + stack.build(endpoint) + end + end + def initialize(controller, action) @controller, @action = controller, action end @@ -88,6 +97,16 @@ module ActionController end end + extlib_inheritable_accessor(:middleware_stack) { ActionDispatch::MiddlewareStack.new } + + def self.use(*args) + middleware_stack.use(*args) + end + + def self.middleware + middleware_stack + end + # Return a rack endpoint for the given action. Memoize the endpoint, so # multiple calls into MyController.action will return the same object # for the same action. @@ -98,8 +117,7 @@ module ActionController # ==== Returns # Proc:: A rack application def self.action(name) - @actions ||= {} - @actions[name.to_s] ||= ActionEndpoint.new(self, name) + ActionEndpoint.for(self, name, middleware_stack) end end end |