diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2007-01-24 20:47:32 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2007-01-24 20:47:32 +0000 |
commit | 6ee09b6a0a548362e8602d56b7db7c03c65512fa (patch) | |
tree | 2704079cb4b4697a1073cab47a01cf53e8851f2a /activesupport/lib | |
parent | ef1d0c1259337638983804ea0f97f25f2b3f02e4 (diff) | |
download | rails-6ee09b6a0a548362e8602d56b7db7c03c65512fa.tar.gz rails-6ee09b6a0a548362e8602d56b7db7c03c65512fa.tar.bz2 rails-6ee09b6a0a548362e8602d56b7db7c03c65512fa.zip |
Increase test coverage for subclasses_of. Closes #7335.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6036 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/extending.rb | 10 |
1 files changed, 5 insertions, 5 deletions
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 |