Hi, 

> >
> > If I were writing this in C++, I'd use templates.  What's 
> the Ruby Way?
> 
> module Extension
>   # this one is really only neede if you
>   # want to inherit this behavior automatically
>   # down the class hierarchy
>   def inherited(cl)
>     cl.extend Extension
>   end
> 
>   def do_my_thing(klass=self)
>     # whatever
>     p klass
>   end
> end
> 
> >> class A
> >>   extend Extension
> >> end

Close, but no banana.

Maybe I'm not doing it right.  Here's what I've got:


class MyBase
  def self.do_my_thing(klass=self)
    p '-----'
  end
end

module Extension
  def inherited(cl)
    cl.extend Extension
  end

  def do_my_thing(klass=self)
    p klass
    super(klass.superclass)
  end
end

class A < MyBase
   extend Extension
end

class B < A
end

class C < B
end

class D < C
end

D.do_my_thing



My output is:

D
"-----"


The output I want is:

D
C
B
A
"-----"


Is this possible (without repeating the definition of do_my_thing)?

Adelle.