From: Robert Dober Date: 2007-06-15T23:04:33+09:00 Subject: Re: class destruction (evil genius metaprogramming) On 6/15/07, dblack@wobblini.net wrote: > Hi -- > > On Fri, 15 Jun 2007, Robert Dober wrote: > > > On 6/15/07, dblack@wobblini.net wrote: > >> Hi -- > >> > >> On Fri, 15 Jun 2007, Rick DeNatale wrote: > >> > >> > kermit.class.instance_methods(false).each{|m| > >> > Muppet.instance_eval("remove_method #{m.inspect}")} > >> > > >> > Note 1. kermit.methods will return all methods inherited or not. > >> > Note 2. remove method is a class method, so it's evaluated in the > >> > context of the class object, hence Muppet.instance_eval > >> > Note 3: you could alternatively pass symbols for the method names > >> > > >> > kermit.class.instance_methods(false).each{|m| > >> > Muppet.instance_eval("remove_method :#{m}")} > >> > >> You can also just use the block form of instance_eval: > >> > >> Muppet.instance_eval { remove_method(m) } > > > > or Muppet.send :remove_method, :m > > If you have a method called "m" :-) Ah I see :(, Probably 50% of my errors come from spurious ":" ARRRRG Muppet.send :remove_method, m ### TESTED ;) Sorry. Robert -- You see things; and you say Why? But I dream things that never were; and I say Why not? -- George Bernard Shaw