I have created a class dynamically, and am trying to add methods to the class. Assume a string represents the command needing to be evaluated by this method.
a = "puts x"
myobject.metaclass.send(:define_method, k){|x|
// cannot do this, obviously
eval(a)
}
Thanks for the help.
Edit:
k is coming from the file also, it would be trivial to just write the classes in ruby instead of reading an alternate file format as a class, but I want to make it as simple as possible to create the templates. looks something like...
generic
do_something:
environment1:
foo arg1 arg2
environment2:
bar arg
baz arg
I know what the method is called and what the method needs to do. I determine the appropriate environment for each class instance at runtime, I just can't seem to dynamically add statements to the method.