From 1aaeb2113b64c9e5a26d7e4a24e868899b89f614 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Sat, 4 Feb 2006 04:50:53 +0000 Subject: 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 --- activesupport/lib/active_support/core_ext/class/removal.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activesupport/lib/active_support/core_ext') 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 -- cgit v1.2.3