From: Phrogz Date: 2007-08-31T05:30:07+09:00 Subject: Re: Add a method to a class at runtime? On Aug 30, 12:58 pm, bwv549 wrote: > # from ri class_eval: > class Thing > end > a = %q{def hello() "Hello there!" end} > Thing.module_eval(a) > puts Thing.new.hello() > Thing.module_eval("invalid code", "dummy", 123) And no need to use strings: module Joi def happy?; true; end end class Foo; end f1 = Foo.new f2 = Foo.new f2.class.class_eval{ include Joi } p f1.happy? #=> true