diff options
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object_and_class.rb | 18 | ||||
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 2 |
2 files changed, 10 insertions, 10 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 bd67b3d1fa..4ad13265d7 100644 --- a/activesupport/lib/active_support/core_ext/object_and_class.rb +++ b/activesupport/lib/active_support/core_ext/object_and_class.rb @@ -1,9 +1,9 @@ class Object #:nodoc: - def remove_subclasses_of(superclass) - subclasses_of(superclass).each do |subclass| - # remove_instance_variables_of(klass) - Object.send(:remove_const, subclass) rescue nil - end + def remove_subclasses_of(*superclasses) + subclasses_of(*superclasses).each do |subclass| + subclass.instance_variables.each { |v| subclass.send(:remove_instance_variable, v) } + Object.send(:remove_const, subclass.to_s) rescue nil + end end def remove_instance_variables_of(klass) @@ -14,11 +14,11 @@ class Object #:nodoc: end end - def subclasses_of(superclass) + def subclasses_of(*superclasses) subclasses = [] ObjectSpace.each_object(Class) do |k| - next if !k.ancestors.include?(superclass) || superclass == k || k.to_s.include?("::") || subclasses.include?(k.to_s) - subclasses << k.to_s + next if (k.ancestors & superclasses).empty? || superclasses.include?(k) || k.to_s.include?("::") || subclasses.include?(k) + subclasses << k end subclasses end @@ -50,6 +50,6 @@ class Class #:nodoc: end def subclasses - Object.subclasses_of(self) + Object.subclasses_of(self).map { |o| o.to_s } end end diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index bb46087582..c37e868b83 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -39,7 +39,7 @@ module Dependencies #:nodoc: end def remove_subclasses_for(*classes) - classes.each { |klass| klass.remove_subclasses } + Object.remove_subclasses_of(*classes) end # LoadingModules implement namespace-safe dynamic loading. |