aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2006-02-04 04:50:53 +0000
committerNicholas Seckar <nseckar@gmail.com>2006-02-04 04:50:53 +0000
commit1aaeb2113b64c9e5a26d7e4a24e868899b89f614 (patch)
tree22823a250c412da5b4a034b951d692ab63c88f8a /activesupport
parent62aa0603b79965c4f48711bc2adf033551be2439 (diff)
downloadrails-1aaeb2113b64c9e5a26d7e4a24e868899b89f614.tar.gz
rails-1aaeb2113b64c9e5a26d7e4a24e868899b89f614.tar.bz2
rails-1aaeb2113b64c9e5a26d7e4a24e868899b89f614.zip
Fix Reloadable to handle the case where a class that has been 'removed' has not yet been garbage collected.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3528 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-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
)