diff options
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/class/removal.rb | 7 |
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 |