Permalink
Browse files

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
  • Loading branch information...
1 parent 689cca1 commit bf92aacf40f946432dbe3c294e26b5516637b8a4 @seckar seckar committed Sep 8, 2005
Showing with 18 additions and 18 deletions.
  1. +2 −0 actionpack/CHANGELOG
  2. +16 −5 actionpack/lib/action_controller/base.rb
  3. +0 −13 actionpack/lib/action_controller/helpers.rb
View
@@ -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
@@ -784,13 +784,24 @@ def reset_session #:doc:
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
@@ -16,11 +16,6 @@ class << self
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 @@ def inherited_with_helper(child)
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

0 comments on commit bf92aac

Please sign in to comment.