On Mon, 18 Sep 2006 19:31:20 +0900, Uncutstone Wu wrote:

> Verno Miller wrote:
>>> Uncutstone Wu wrote:
>>> ...  As you said, a man is not always a teacher. So, rather than including Teacher 
>>> into class Man, it's better to extend a Man object individually as in the following code.
> 
> 
> But if I want Teacher to be a class at some other occasions,and sometime 
> I want it to be module so that it could be able to be mixed into other 
> objects.
> 
> Best regards.
>

class Person; end
class Man < Person; end
module TeacherModule; end
class Teacher; include TeacherModule; end

then you can include TeacherModule into any Man objects you want, and if
you define all of your Teacher methods on the TeacherModule, then they
will automatically appear in the teacher class.

If you still want to look at delegates, have a look at the standard
Delegator and Forwardable libraries.

Sadly, I lack more information to tell you whether there's something even
more clever you can do by taking advantage of duck typing.

--Ken

-- 
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/