From 76cd4cb27e2ec197c7f62082334d5d7211fd2d19 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sat, 12 Sep 2009 15:38:34 -0500 Subject: Memoize in the endpoint. --- actionpack/lib/action_controller/metal.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'actionpack/lib') 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 -- cgit v1.2.3