From: Trans Date: 2005-08-12T23:46:12+09:00 Subject: Re: Dear RubyGems: Perhaps a better way to override require... Mauricio Fern�ndez wrote: > On Fri, Aug 12, 2005 at 06:14:21AM +0900, Ryan Leavengood wrote: > > I often prefer something like: > > batsman@tux-chan:/tmp$ cat gfdhoidhi.rb > > module Kernel > meth = instance_method(:require) > define_method(:require) do |s| > puts "New require(1), reusing old definition" > meth.bind(self).call(s) > end > end > > > module Kernel > meth = instance_method(:require) > define_method(:require) do |s| > puts "New require(2), reusing old definition" > meth.bind(self).call(s) > end > end > > require 'English' > puts $PID > batsman@tux-chan:/tmp$ ruby gfdhoidhi.rb > New require(2), reusing old definition > New require(1), reusing old definition > 4582 > > especially in 1.9, of course. Although, there still needs to be a way to selectively bypass. For instance I have a method Kernel#require_all, which requires files based on a glob pattern eg. require_all 'dir/*' But I can't have this routing through my escaping require; I need to by pass that. T.