From: GOTO Kentaro Date: 2002-07-17T16:10:28+09:00 Subject: Re: alias_method problem At Wed, 17 Jul 2002 05:09:08 +0900, Steve Tuckner wrote: > I too have run in to this and implemented an ugly kludge to deal with it > (instead of taking the time to figure it out). I have another trick. require "noreload" class Foo include NoReload alias_method :oldone, :newone def newone oldone end no_reload_upto_here! end noreload uses a continuation but not tested enough. % cat noreload.rb class ReloadError < StandardError end module NoReload def self.append_features(mod) super mod.class_eval do unless @no_reload_included_position @no_reload_included_position = caller[4] else if @no_reload_included_position == caller[4] @no_reload_upto_here or raise ReloadError, "`no_reload_upto_here!' wasn't called in previous definition", caller[3..-1] @no_reload_upto_here.call end end def mod.no_reload_upto_here! @no_reload_upto_here and raise ReloadError, "`no_reload_upto_here!' called twice", caller[0] callcc{|@no_reload_upto_here|} end end end end Full version: http://www.notwork.org/~gotoken/ruby/p/as-is/noreload.rb http://www.notwork.org/~gotoken/ruby/p/as-is/noreload-test.rb