From: Elias Athanasopoulos Date: 2004-05-08T03:19:23+09:00 Subject: Re: class_missing ? On Sat, May 08, 2004 at 03:09:15AM +0900, Mark Hubbart wrote: > > On May 7, 2004, at 9:58 AM, Elias Athanasopoulos wrote: > > >Hello! > > > >Is there something similar to method_missing for classes? > > > >I.e. overload a method of Object or handle an exception > >when a 'Foo.new' is called and class Foo does not exist. > > Something like this? > > def Object.const_missing(sym) > Object.const_set( sym, Class.new() ) > end > ==>nil > Foo.new > ==># > Bar.new > ==># > Baz.new > ==># Exactly! Thanx (to Dmitry also). :-) Ruby never fails to surprise - not in the common 'bad' sense - me! Regards, -- University of Athens I bet the human brain Physics Department is a kludge --Marvin Minsky