From 83e29b9773ac113ceacb1e36c2f333d692de2573 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 15 Jul 2008 22:51:16 -0500 Subject: Removed config.action_view.cache_template_loading, use config.cache_classes instead --- actionpack/lib/action_view/paths.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_view/paths.rb') diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/paths.rb index b0ab7d0c67..c7a5df762f 100644 --- a/actionpack/lib/action_view/paths.rb +++ b/actionpack/lib/action_view/paths.rb @@ -16,6 +16,14 @@ module ActionView #:nodoc: end class Path #:nodoc: + def self.eager_load_templates! + @eager_load_templates = true + end + + def self.eager_load_templates? + @eager_load_templates || false + end + attr_reader :path, :paths delegate :to_s, :to_str, :inspect, :to => :path @@ -37,6 +45,9 @@ module ActionView #:nodoc: @paths = {} templates_in_path do |template| + # Eager load memoized methods and freeze cached template + template.freeze if self.class.eager_load_templates? + @paths[template.path] = template @paths[template.path_without_extension] ||= template end @@ -48,10 +59,7 @@ module ActionView #:nodoc: def templates_in_path (Dir.glob("#{@path}/**/*/**") | Dir.glob("#{@path}/**")).each do |file| unless File.directory?(file) - template = Template.new(file.split("#{self}/").last, self) - # Eager load memoized methods and freeze cached template - template.freeze if Base.cache_template_loading - yield template + yield Template.new(file.split("#{self}/").last, self) end end end -- cgit v1.2.3