From 6ee09b6a0a548362e8602d56b7db7c03c65512fa Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Wed, 24 Jan 2007 20:47:32 +0000 Subject: Increase test coverage for subclasses_of. Closes #7335. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6036 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/core_ext/object/extending.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/object/extending.rb b/activesupport/lib/active_support/core_ext/object/extending.rb index e15b4bf385..8a82f71c0f 100644 --- a/activesupport/lib/active_support/core_ext/object/extending.rb +++ b/activesupport/lib/active_support/core_ext/object/extending.rb @@ -6,11 +6,11 @@ class Object #:nodoc: def subclasses_of(*superclasses) subclasses = [] ObjectSpace.each_object(Class) do |k| - next if # Exclude this class if - (k.ancestors & superclasses).empty? || # It's not a subclass of our supers - superclasses.include?(k) || # It *is* one of the supers - eval("! defined?(::#{k})") || # It's not defined. - eval("::#{k}").object_id != k.object_id + next unless # Exclude this class unless + superclasses.any? { |superclass| k < superclass } && # It *is* a subclass of our supers + eval("defined?(::#{k}) && ::#{k}.object_id == k.object_id") # It *is* defined + # Note that we check defined? in case we find a removed class that has + # yet to be garbage collected. subclasses << k end subclasses -- cgit v1.2.3