Re: class destruction (evil genius metaprogramming)
by Robert Dober other posts by this author
Jun 15 2007 7:04AM messages near this date
Re: class destruction (evil genius metaprogramming)
|
Re: class destruction (evil genius metaprogramming)
On 6/15/07, dblack@[...].net <dblack@[...].net> wrote:
> Hi --
>
> On Fri, 15 Jun 2007, Robert Dober wrote:
>
> > On 6/15/07, dblack@[...].net <dblack@[...].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
Thread:
Giles Bowkett
Rick DeNatale
dblack
Robert Dober
dblack
Robert Dober
Giles Bowkett
dblack
Stephen Smith
Nathan Taylor-Hoover
Giles Bowkett
dblack
Giles Bowkett
Rick DeNatale
dblack
Devin Mullins
dblack
Gregory Brown
Giles Bowkett
|