diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object_and_class.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/object_and_class.rb b/activesupport/lib/active_support/core_ext/object_and_class.rb index b8e9d27217..968c3bdeac 100644 --- a/activesupport/lib/active_support/core_ext/object_and_class.rb +++ b/activesupport/lib/active_support/core_ext/object_and_class.rb @@ -1,6 +1,13 @@ class Object #:nodoc: def remove_subclasses_of(superclass) - subclasses_of(superclass).each { |subclass| Object.send(:remove_const, subclass) rescue nil } + subclasses_of(superclass).each do |subclass| + ObjectSpace.each_object(Class) do |k| + if k.to_s == subclass + k.instance_variables.each { |v| k.send(:remove_instance_variable, v) } + end + end + Object.send(:remove_const, subclass) rescue nil + end end def subclasses_of(superclass) |