facets
facets copied to clipboard
Eigen vs Module methods
I am considering adding the method alias_class_method
to the Module class. However, it seems wasteful to have to add a special method for this, just as it seems wasteful for similar methods like class_accessor
. We end up with a bunch of methods that are nothing more then copies of methods that already exist, but acting on the singleton class instead.
Facets has Kernel#eigen
which can be used like so:
class Foo
eigen.alias_method :foo, :bar
eigen.attr_accessor :baz
end
Not sure I like the eigen
name. It used to be called meta
but that seemed way too generic. But the question is: Is eigen
a better approach? Or should we just be happy with a bunch of extra module methods? Or should we just support both?
Without expressing any personal preference I believe that singleton[class]
, meta[class]
and eigen[class]
are used with descending frequency.
Personally I prefer metaclass
Thanks, that helps. I'll start the process of deprecating eigen
. The term eigenclass
was _why's baby. I suppose he's been gone long enough now.
I'm still not sure if I should bother to add alias_class_method
. Which would you prefer to see in code:
class Foo
metaclass.alias_method :foo, :bar
end
Or
class Foo
alias_class_method :foo, :bar
end
I prefer the first, its semantic is clear for me, although you chose a good name, it still is only a name, I feel it does not enough "work" to justify its existence.
Just my 2c.
BTW
Nice to know about the origin of eigen
.