On Wed, Nov 28, 2007 at 11:35:00AM +0900, rbysamppi / gmail.com wrote:
> As a beginner, I'm having trouble converting the metaprogramming in
> Dwemthy's Array (http://poignantguide.net/dwemthy/) into a convenient
> mixin that I can use for many classes. The trouble seems to be the
> "def self." declarations, but I'm not too sure; in any
> case, .metaclass and .traits don't seem to be mixing in. What should I
> change?

Hey, so, yes, this is what Dwemthy has been talking about all along,
this is exactly what caused him to start grinding his teeth and his
blood pressure went through the roof and he got a contagious clubbed
foot and so on, simply because he didn't know or have the slightest
inkling concerning append_features.

Mixins only mix instance methods. However, our friend Nobu Nakada
has just the trick. -> http://redhanded.hobix.com/bits/hyperextended.html

Basically, put all the class methods in their own module.  Then mix
the module into the Dwemthy module using `extend`.  Then add an
`append_features` method to the Dwemthy module that mixes both into
future mixees.  It's a bit of a trip, but still only about five
extra lines of code.

Nobu lays low, but he's filthy smart that one.

_why