diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-07-07 14:48:16 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-07-07 14:48:16 +0000 |
commit | 703ac4c5ac68f68b48debd1bfc352cd687b2df30 (patch) | |
tree | 8606fe9c0f52beabf8b17decd79c39dcae9e0ad7 /activesupport/lib/active_support | |
parent | b640a647603f869eca5cbecce3dbc94cb47447ad (diff) | |
download | rails-703ac4c5ac68f68b48debd1bfc352cd687b2df30.tar.gz rails-703ac4c5ac68f68b48debd1bfc352cd687b2df30.tar.bz2 rails-703ac4c5ac68f68b48debd1bfc352cd687b2df30.zip |
Added more efficient implementation of the development mode reset of classes #1638 [Chris McGrath]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1761 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
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. |