ptkwt / shell1.aracnet.com (Phil Tomson) writes:

> This is from a discussion that came up on comp.object....
> 
> Let's say you have a Person class that you instantiate.  Now a Person can 
> have different roles in life, let's say in this case there is the Student 
> role and (after graduation) the Employee role.  So, we could do:
> 
> Is there something like...
> person.unextend Student (?)
> person.unmixin Student (?)
> 

There is undef/remove_method that you can use. Then you can write 

module Student
def studentMethods { ["drinkCoke", "study", "socialise", "date"] }
def studentUnbecome
   studentMethods.each {|x| undef_method x}
end; end

I dont think there is any way to identify the origin of a
method. You cannot say for sure whether method drinkCoke comes from
mod Student or mod Employee, or even from class Person. Thus, you have
to keep track of what each module introduces.

Anyway, the analogy used, Person becoming Student and then
Employee, is a bit incorrect. A person modifies his behaviour, not
drop his behaviour through the transition. For example, I still drink
coke and study even though I'm not a student anymore.


YS.