From: Michael Schuerig Date: 2005-09-18T22:27:54+09:00 Subject: Re: Finding out if a method is already redefined David A. Black wrote: > Hi -- > > On Sun, 18 Sep 2005, Michael Schuerig wrote: > >> >> My problem occurs in the context of Rails, but is really core Ruby. >> In its "development environment" Rails uses load, not require, to >> load files anew for each request. This is to enable changes to the >> running application. I'm running into a problem with this mechanism >> when redefining a method *and* referring to the old method in the >> redefined one. When this redefinition happens twice, it results in an >> infinite recursion. I've tried to guard the redefinition with a check >> for the new method, but this doesn't work, the new alias is not >> recognized. >> >> unless method_defined?(:method_new) >> alias_method :method_old, :method >> def method_new(options = {}) >> ... >> method_old(options) >> end >> alias_method :method, :method_new >> end >> >> What do I have to do to make this work? > > I can't duplicate your problem. Here's what I'm doing: [example snipped] Yes, I know, I tried the same and outside of Rails it works nicely. Apparently, Rails does more things than simply re-loading. Michael -- Michael Schuerig There is no matrix, mailto:michael@schuerig.de only reality. http://www.schuerig.de/michael/ --Lawrence Fishburn