Re: class destruction (evil genius metaprogramming)
by dblack other posts by this author
Jun 15 2007 6:50AM messages near this date
Re: class destruction (evil genius metaprogramming)
|
Re: class destruction (evil genius metaprogramming)
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" :-)
David
--
* Books:
RAILS ROUTING (new! http://safari.awprofessional.com/9780321509246)
RUBY FOR RAILS (http://www.manning.com/black)
* Ruby/Rails training
& consulting: Ruby Power and Light, LLC (http://www.rubypal.com)
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
|