From: John Lam Date: 2005-12-15T13:07:57+09:00 Subject: Dynamically adding methods to a Ruby class ------=_Part_1009_17822430.1134619669875 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 =3D Class.new obj.class_eval %{ def initialize ... end def method_missing(name, *params) ... end } const_set(symbol, obj) end end 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 ------=_Part_1009_17822430.1134619669875--