ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved