From 21db5c864b626f84ae3c48978980a6634b3892e1 Mon Sep 17 00:00:00 2001 From: thedarkone Date: Thu, 19 Feb 2009 03:23:34 +0100 Subject: [PATCH] Fix an edge case where we might encounter some random left-over compiled methods. --- actionpack/lib/action_view/reloadable_template.rb | 13 +++++-------- actionpack/lib/action_view/template.rb | 4 ---- .../test/template/compiled_templates_test.rb | 12 ------------ 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/actionpack/lib/action_view/reloadable_template.rb b/actionpack/lib/action_view/reloadable_template.rb index 3081be6..619dba4 100644 --- a/actionpack/lib/action_view/reloadable_template.rb +++ b/actionpack/lib/action_view/reloadable_template.rb @@ -78,7 +78,7 @@ module ActionView #:nodoc: def initialize(*args) super - @compiled_methods = [] + undef_my_compiled_methods! # we don't ever want to get frozen extend Unfreezable @@ -106,14 +106,11 @@ module ActionView #:nodoc: self end + # remove any compiled methods that look like they might belong to me def undef_my_compiled_methods! - @compiled_methods.each {|comp_method| ActionView::Base::CompiledTemplates.send(:remove_method, comp_method)} - @compiled_methods.clear - end - - def compile!(render_symbol, local_assigns) - super - @compiled_methods << render_symbol + ActionView::Base::CompiledTemplates.public_instance_methods.grep(/#{Regexp.escape(method_name_without_locals)}(?:_locals_)?/).each do |m| + ActionView::Base::CompiledTemplates.send(:remove_method, m) + end end end diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index b8e2165..6347800 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -57,10 +57,6 @@ module ActionView #:nodoc: end class EagerPath < Path - def initialize(path) - super - end - def load! return if @loaded diff --git a/actionpack/test/template/compiled_templates_test.rb b/actionpack/test/template/compiled_templates_test.rb index a8f8455..ab56fc1 100644 --- a/actionpack/test/template/compiled_templates_test.rb +++ b/actionpack/test/template/compiled_templates_test.rb @@ -5,18 +5,6 @@ class CompiledTemplatesTest < Test::Unit::TestCase def setup @compiled_templates = ActionView::Base::CompiledTemplates - - # first, if we are running the whole test suite with ReloadableTemplates - # try to undef all the methods through ReloadableTemplate's interfaces - unless ActionView::Base.cache_template_loading? - ActionController::Base.view_paths.each do |view_path| - view_path.paths.values.uniq!.each do |reloadable_template| - reloadable_template.undef_my_compiled_methods! - end - end - end - - # just purge anything that's left @compiled_templates.instance_methods.each do |m| @compiled_templates.send(:remove_method, m) if m =~ /^_run_/ end -- 1.6.0.1