> How would I write a function to create additional methods in a > class which act as wrappers around already existing methods? > > Example. > > class Test > def foo > puts "foo" > end > end > > Now I want to call a magic procedure, like > > double_it(Test, "foo", "foo2") > > which would have the effect of doing > > class Test > def foo2 > foo > foo > end > end > > I can do > > Test.class_eval { > def foo2 > foo > foo > end > } > to add methods, but I don't know how to write the method at run-time. Does this work for you? class Test def foo puts "foo" end end def double_it(c,string,meth) c.class_eval "def #{meth}\n #{string}\n #{string}\n end" end double_it(Test, "foo", "foo2") t = Test.new puts t.foo2 regards, -joe