aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object/extending.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-06-12 17:48:30 -0500
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-06-12 17:48:30 -0500
commitea3a7e1bb1efc8b3ca10c4163bc116f3d5e23af1 (patch)
treea3cce25be0c613a8e1444e1d0ff53aaed3497057 /activesupport/lib/active_support/core_ext/object/extending.rb
parent556204abaf95f7c995576cb1358f13de406682ab (diff)
parentdd4181f47dc0f166eb5d3e47a4a0dc1594cc5669 (diff)
downloadrails-ea3a7e1bb1efc8b3ca10c4163bc116f3d5e23af1.tar.gz
rails-ea3a7e1bb1efc8b3ca10c4163bc116f3d5e23af1.tar.bz2
rails-ea3a7e1bb1efc8b3ca10c4163bc116f3d5e23af1.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/extending.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/object/extending.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/extending.rb b/activesupport/lib/active_support/core_ext/object/extending.rb
index 43a2be916e..082e98a297 100644
--- a/activesupport/lib/active_support/core_ext/object/extending.rb
+++ b/activesupport/lib/active_support/core_ext/object/extending.rb
@@ -3,17 +3,18 @@ class Object
Class.remove_class(*subclasses_of(*superclasses))
end
+ # Exclude this class unless it's a subclass of our supers and is defined.
+ # We check defined? in case we find a removed class that has yet to be
+ # garbage collected. This also fails for anonymous classes -- please
+ # submit a patch if you have a workaround.
def subclasses_of(*superclasses) #:nodoc:
subclasses = []
- # Exclude this class unless it's a subclass of our supers and is defined.
- # We check defined? in case we find a removed class that has yet to be
- # garbage collected. This also fails for anonymous classes -- please
- # submit a patch if you have a workaround.
- ObjectSpace.each_object(Class) do |k|
- if superclasses.any? { |superclass| k < superclass } &&
- (k.name.blank? || eval("defined?(::#{k}) && ::#{k}.object_id == k.object_id"))
- subclasses << k
+ superclasses.each do |sup|
+ ObjectSpace.each_object(class << sup; self; end) do |k|
+ if k != sup && (k.name.blank? || eval("defined?(::#{k}) && ::#{k}.object_id == k.object_id"))
+ subclasses << k
+ end
end
end