Subject: Re: Add a method to a class at runtime?
From: bwv549 <jtprince gmail.com>
Date: Fri, 31 Aug 2007 04:00:10 +0900
References: 266837
In-reply-to: 266837
Note to self,
class_eval or module_eval should work
# 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)