John Lam wrote: > I just finished writing the first spike for my Ruby CLR bridge tonight, > and > I'm wondering if there might be a better (or more efficient) way to add > instance methods to a class object than this: > > class Module > def const_missing(symbol) > obj = Class.new > obj.class_eval %{ > def initialize > ... > end > > def method_missing(name, *params) > ... > end > } > const_set(symbol, obj) > end > end Not really, except for using define_method (which has some limitations that would probably make it unsuitable for a #method_missing implementation). The 'Class methods' thread had pretty much this exact implementation.. Perhaps some sort of a prototype-based approach? > Thanks, > -John > http://www.iunknown.com > > PS If you're wondering what the code in the ... blocks do, read my > write-up > of this code at: > http://www.iunknown.com/articles/2005/12/14/hello-rubyclr E -- Posted via http://www.ruby-forum.com/.