From bf92aacf40f946432dbe3c294e26b5516637b8a4 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Thu, 8 Sep 2005 12:08:24 +0000 Subject: Avoid extending view instance with helper modules each request. Closes #1979 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2152 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_controller/base.rb | 21 ++++++++++++++++----- actionpack/lib/action_controller/helpers.rb | 13 ------------- 3 files changed, 18 insertions(+), 18 deletions(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index b53aceccb5..b55bd14f20 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Avoid extending view instance with helper modules each request. Closes #1979 + * Performance improvements to CGI methods. Closes #1980 [Skaes] * Added :post option to UrlHelper#link_to that makes it possible to do POST requests through normal ahref links using Javascript diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 5f4cd5a932..5fbbab8647 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -784,13 +784,24 @@ module ActionController #:nodoc: end private - def initialize_template_class(response) - begin - response.template = template_class.new(template_root, {}, self) - rescue - raise "You must assign a template class through ActionController.template_class= before processing a request" + def self.view_class + unless @view_class + # create a new class based on the default template class and include helper methods + logger.debug "defining view class for #{name}" if logger + @view_class = Class.new(ActionView::Base) + @view_class.send(:include, master_helper_module) end + @view_class + end + + def self.view_root + @view_root ||= template_root + end + + def initialize_template_class(response) + raise "You must assign a template class through ActionController.template_class= before processing a request" unless @@template_class + response.template = self.class.view_class.new(self.class.view_root, {}, self) @performed_render = @performed_redirect = false end diff --git a/actionpack/lib/action_controller/helpers.rb b/actionpack/lib/action_controller/helpers.rb index 86653e4f06..df381079eb 100644 --- a/actionpack/lib/action_controller/helpers.rb +++ b/actionpack/lib/action_controller/helpers.rb @@ -16,11 +16,6 @@ module ActionController #:nodoc: alias_method :inherited_without_helper, :inherited alias_method :inherited, :inherited_with_helper end - - # Wrap initialize_template_class to extend new template class - # instances with the master helper module. - alias_method :initialize_template_class_without_helper, :initialize_template_class - alias_method :initialize_template_class, :initialize_template_class_with_helper end end @@ -124,13 +119,5 @@ module ActionController #:nodoc: end end end - - private - # Extend the template class instance with our controller's helper module. - def initialize_template_class_with_helper(response) - returning(initialize_template_class_without_helper(response)) do - response.template.extend self.class.master_helper_module - end - end end end -- cgit v1.2.3