aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/core_ext/class/removal.rb7
-rw-r--r--activesupport/test/reloadable_test.rb7
3 files changed, 9 insertions, 7 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 7c92daf5ae..6120f877e5 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fix Reloadable to handle the case where a class that has been 'removed' has not yet been garbage collected. [Nicholas Seckar]
+
* Don't allow Reloadable to be included into Modules.
* Remove LoadingModule. [Nicholas Seckar]
diff --git a/activesupport/lib/active_support/core_ext/class/removal.rb b/activesupport/lib/active_support/core_ext/class/removal.rb
index 468c77d81b..42cb9f6e4e 100644
--- a/activesupport/lib/active_support/core_ext/class/removal.rb
+++ b/activesupport/lib/active_support/core_ext/class/removal.rb
@@ -9,8 +9,15 @@ class Class #:nodoc:
def remove_class(*klasses)
klasses.each do |klass|
+ # Skip this class if there is nothing bound to this name
+ next unless defined?(klass.name)
+
basename = klass.to_s.split("::").last
parent = klass.parent
+
+ # Skip this class if it does not match the current one bound to this name
+ next unless klass = parent.const_get(basename)
+
parent.send :remove_const, basename unless parent == klass
end
end
diff --git a/activesupport/test/reloadable_test.rb b/activesupport/test/reloadable_test.rb
index fb1d61740d..8366471e4a 100644
--- a/activesupport/test/reloadable_test.rb
+++ b/activesupport/test/reloadable_test.rb
@@ -5,9 +5,6 @@ require File.dirname(__FILE__) + '/../lib/active_support/reloadable'
module ReloadableTestSandbox
- module AModuleIncludingReloadable
- include Reloadable
- end
class AReloadableClass
include Reloadable
end
@@ -43,9 +40,6 @@ module ReloadableTestSandbox
end
class ReloadableTest < Test::Unit::TestCase
- def test_modules_do_not_receive_reloadable_method
- assert ! ReloadableTestSandbox::AModuleIncludingReloadable.respond_to?(:reloadable?)
- end
def test_classes_receive_reloadable
assert ReloadableTestSandbox::AReloadableClass.respond_to?(:reloadable?)
end
@@ -76,7 +70,6 @@ class ReloadableTest < Test::Unit::TestCase
)
non_reloadables = %w(
ANonReloadableSubclass
- AModuleIncludingReloadable
OnlySubclassesReloadable
)