diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-09-12 15:38:34 -0500 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-09-12 15:38:34 -0500 |
commit | 76cd4cb27e2ec197c7f62082334d5d7211fd2d19 (patch) | |
tree | 80b0e0a843ae3d88a0b2ae0da7769379d0624f69 /actionpack/lib | |
parent | ddb4600ce608b14f9fa07bf1196b78e1d43ad999 (diff) | |
download | rails-76cd4cb27e2ec197c7f62082334d5d7211fd2d19.tar.gz rails-76cd4cb27e2ec197c7f62082334d5d7211fd2d19.tar.bz2 rails-76cd4cb27e2ec197c7f62082334d5d7211fd2d19.zip |
Memoize in the endpoint.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/metal.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb index 296d359391..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 @@ -108,11 +117,7 @@ module ActionController # ==== Returns # Proc:: A rack application def self.action(name) - @actions ||= {} - @actions[name.to_s] ||= begin - endpoint = ActionEndpoint.new(self, name) - middleware_stack.build(endpoint) - end + ActionEndpoint.for(self, name, middleware_stack) end end end |