I am writing the AS core extensions guide, and would like to know your
opinion about Class#subclasses:
AS defines Class#subclasses, it returns the name of all descendants
(strings). Same as AC::Base.subclasses.
AR::Base.subclasses on the other hand returns all descendants
(classes), and it is protected.
The guide could warn about AR::Base. We could also redefine
AR::Base.subclasses to match the rest (I'd volunteer). ack says there
are not a lot of occurrences, but it wouldn't be backwards compatible.
I first thought about changing AR because at least that is a protected
method and it could be the case that it breaks less code.
But all being equal, I'd expect subclasses to return class objects
indeed, for example Object#subclasses_of does, and anyway that is what
the name would suggest to me.
I've seen that the classes in the framework that need #subclasses
implement their own version using the inherited hook.
It turns out that Class#subclasses was not being used in the
framework, Jeremy suggested it shouldn't be a core extension in that
case and we've removed it.
That in turn unrolled a series of related utilities that were unused, they are:
So, if some classes (like ActiveRecord) in the framework implement their own subclasses, why not implement it once in AS and remove those other implementations?
Sounds good because there are 4 o 5 of them. I think they are
equivalent except perhaps for visibility which is not probably big
deal if we uniform this. I'll have a look at it.