Since I’ve come upon the issue again, I reckon, it’s as good time as
any to put this in the air.
The issue, again, is that module class methods are not
“inherited” (for lack of a better word). In the past I’ve argued for
this, but it has been consistently argued down due to the extraneous
methods it would add to classes. However, it occurs to me that the
core problem that I continually face for the lack of this, it simply
that I can’t call super in a class level method and expect it to move
through included module methods. The reason this is such a problem, it
that it makes it very difficult to create an “inheriting variable”.
This is the reason Facets contains inheritor.rb, but even that is
limited to only simple cases.
To make this clear, here is a simple example of the idea:
[ ‘Xfoo’ ]
[ ‘Mfoo’ ] + super
class Y < X
[ ‘Yfoo’ ] + super
Y.foo #=> [ ‘Yfoo’, ‘Xfoo’ ]
As you can see there is no ‘Mfoo’ in the list.
If your’re wondering how this is useful, consider any use-case where
meta-information needs to associated to a method. Just as methods are
inherited so too their meta-information. Possible uses are annotations
and pre, post, around wraps.
So the thought I had today is that rather then full inclusion at the
class-level, that we might simply have an alternate #super call that
would traverse the include modules class methods as well as classes. I
realize that might be tricky to implement, but it would satisfy the
need without all the unwanted baggage.