Re: class destruction (evil genius metaprogramming)
by Stephen Smith other posts by this author
Jun 14 2007 9:04PM messages near this date
Re: class destruction (evil genius metaprogramming)
|
Re: class destruction (evil genius metaprogramming)
Why should this inspire fear?
On 6/14/07, Giles Bowkett <gilesb@[...].com> 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}")}
>
> Muahahaha! That was awesome! Soon the world will quake in fear when I
> put this information to use!
>
> But why doesn't this work?
>
> >> kermit.methods(false).each do |m|
> ?> Object.instance_eval("remove_method :#{m}")
> >> end
> => []
> >> kermit.methods
> => 53
>
> I tried it with Kernel also and no dice.
>
> Tried it with something else, though, and got a great error message:
>
> (eval):1: warning: removing `initialize' may cause serious problem
>
> Muahahaha!
>
> --
> Giles Bowkett
>
> Blog: http://gilesbowkett.blogspot.com
> Portfolio: http://www.gilesgoatboy.org
>
>
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
|