aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
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/lib/active_support/core_ext
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/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/class/removal.rb7
1 files changed, 7 insertions, 0 deletions
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