From: Blackie Date: 2007-10-20T04:05:08+09:00 Subject: Puzzle...cleaner way to redefine a method? Here's a puzzle. There must be a cleaner way to do this. I would like to have users of this class be able to call "set_wrapper" and define pre and post behavior on the "working" method. The only simple way I've found is evaling a string the redefines "working". Searching threads on instance and class_eval tends to turn up an oil slick of arguments and misinformation. Help is apprecaited! ~~~~~~~~~~ class Thing def set_wrapper(string) eval(string) end def working yield end def main working do p 'test' end end end a = Thing.new a.main a.set_wrapper("def working; p 'pre'; yield; p 'post'; end") a.main