From: Robert Dober Date: 2007-08-24T20:37:07+09:00 Subject: Re: Dynamic methods On 8/24/07, Robert Dober wrote: > > class A > class << self > alias_method :old_new, :new > def new *args, &block > o = old_new( *args, &block ) > o.instance_eval do > def ara; value end > end > o > end > end > end ## this does the trick, simple concise, trivial :( well we wish it were. > ## and there are issues with the alias it is a potential redefeinition disaster the above really su..., sorry class A alias_method :old_init, :initialize def initialize *args, &blk old_init( *args, &blk ) instance_eval do def ara; value end end end end # the issues remain though, we could apply the method redefintion hammer Pit and Ara came up with and just redefine initialize like that, but that would make it about 100 lines I guess :( Robert -- I'm an atheist and that's it. I believe there's nothing we can know except that we should be kind to each other and do what we can for other people. -- Katharine Hepburn