Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 2152

Show
Ignore:
Timestamp:
09/08/05 12:08:24 (3 years ago)
Author:
ulysses
Message:

Avoid extending view instance with helper modules each request. Closes #1979

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r2151 r2152  
    11*SVN* 
     2 
     3* Avoid extending view instance with helper modules each request. Closes #1979 
    24 
    35* Performance improvements to CGI methods. Closes #1980 [Skaes] 
  • trunk/actionpack/lib/action_controller/base.rb

    r2095 r2152  
    785785     
    786786    private 
     787      def self.view_class 
     788        unless @view_class 
     789          # create a new class based on the default template class and include helper methods 
     790          logger.debug "defining view class for #{name}" if logger 
     791          @view_class = Class.new(ActionView::Base) 
     792          @view_class.send(:include, master_helper_module) 
     793        end 
     794        @view_class 
     795      end 
     796 
     797      def self.view_root 
     798        @view_root ||= template_root 
     799      end 
     800 
    787801      def initialize_template_class(response) 
    788         begin 
    789           response.template = template_class.new(template_root, {}, self) 
    790         rescue 
    791           raise "You must assign a template class through ActionController.template_class= before processing a request" 
    792         end 
     802        raise "You must assign a template class through ActionController.template_class= before processing a request" unless @@template_class 
    793803         
     804        response.template = self.class.view_class.new(self.class.view_root, {}, self) 
    794805        @performed_render = @performed_redirect = false 
    795806      end 
  • trunk/actionpack/lib/action_controller/helpers.rb

    r1425 r2152  
    1717          alias_method :inherited, :inherited_with_helper 
    1818        end 
    19  
    20         # Wrap initialize_template_class to extend new template class 
    21         # instances with the master helper module. 
    22         alias_method :initialize_template_class_without_helper, :initialize_template_class 
    23         alias_method :initialize_template_class, :initialize_template_class_with_helper 
    2419      end 
    2520    end 
     
    125120        end         
    126121    end 
    127  
    128     private 
    129       # Extend the template class instance with our controller's helper module. 
    130       def initialize_template_class_with_helper(response) 
    131         returning(initialize_template_class_without_helper(response)) do 
    132           response.template.extend self.class.master_helper_module 
    133         end 
    134       end 
    135122  end 
    136123end