From: Robert Klemme Date: 2005-04-02T16:24:44+09:00 Subject: Re: Kernel.load() behaviour "Andrew Walrond" schrieb im Newsbeitrag news:200504020041.35224.andrew@walrond.org... > On Saturday 02 April 2005 00:34, Andrew Walrond wrote: >> My final solution, taking the above into account: >> >> c.rb >> class Glibc >> end >> >> b.rb >> inline 'c.rb' >> >> class Gcc >> end >> >> a.rb >> module Packages >> def Packages.inline(filename) >> eval(IO.readlines(filename).join,nil,filename) You can shorten that to eval( File.read(filename), nil, filename ) >> end >> inline('c.rb') >> end >> >> Packages::Gcc.new >> Packages::Glibc.new >> > > My final puzzle before sleep; How to throw an exception if any of the > package > files try to use require() or load() instead of inline() ? (My package > developers might forget and pollute the global namespace) > > Is there a neat way? I posted an approach for temporarily exchanging methods a while ago which can be used for this under subject "Mocking new and other class methods": module Kernel private def mock(obj, sym, mock) cl = class <