Subclasses_of - why does it ignore subclasses within modules

ActiveSupport provides a method Object.subclasses_of, to give the
subclasses of a given class. However, it ignores any subclass within
a module, so :

class A
end

class B < A
end

Object.subclasses_of(A) # returns [B]

module C
class D < A
end
end

Object.subclasses_of(A) # returns [B], even though C::smiley: is also a
subclass of A

class E < C::smiley:
end

Object.subclasses_of(A) # returns [B, E], even though C::smiley: isn’t
returned

This behaviour has been very deliberately built into the code, but
seems to be plainly wrong. Can anyone provide any insight why this is
so?

Tom

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs