From: Gavin Sinclair Date: 2004-09-14T08:18:59+09:00 Subject: Re: traits & roles Phil wrote: > So you might have: > > class Baz > end > > baz = Baz.new > baz.extend Foo #baz now has Foo 'traits' > > ....and later you might want to do: > baz.unextend Foo #remove the Foo 'traits' from baz > > ....later on you could add another set of traits to baz: > baz.extend OtherTraits > > Of course there is no 'unextend', but there are probably ways to > implement this. For example, you could get a list of all of the methods > of Foo and undef them in the baz object (couldn't you?) I'd expect a proper implementation of 'unextend' to just "peel away a layer of methods", not actually remove them. So... module Foo1 def foo; "foo1"; end end module Foo2 def foo; "foo2"; end end class X end x = X.new x.foo # error x.extend Foo1 x.foo # "foo1" x.extend Foo2 x.foo # "foo2" x.unextend Foo2 x.foo # "foo1" Gavin