Hi --

On Tue, 17 Feb 2004, Phil Tomson wrote:

> It has been brought up a few times here in the past: 
> Sometimes you want an object's role to change so it would be nice if
> there were some sort of uninclude <module> or unextend <module>
> methods.
> 
> In the meantime, it probably wouldn't be too hard to 'roll your own'
> uninclude.  Just get the list of instance methods from the module and
> undef_method <methname> in the class.  Something like:
> 
>  class Module
>    def uninclude(mod)
>      mod.instance_methods.each {|meth|
>        undef_method meth
>      }
>    end
>  end
> 
> ....I'm still figuring out how to do unextend (which is arguably more
> useful than uninclude).

Maybe something like:

  class Object
    def unextend(mod)
      (class << self; self; end) .class_eval <<-EOE
	mod.instance_methods.each {|meth| undef_method(meth) }
      EOE
    end
  end


David

-- 
David A. Black
dblack / wobblini.net