From: Joel VanderWerf Date: 2010-06-15T01:12:36+09:00 Subject: Re: Loading a module without polluting my namespace Hagbard Celine wrote: > Thanks for your reply but I'm afraid that doesn't solve my problem. I > stumbled upon the optional argument of `load' as well but it prevents me > from accessing the loaded module. I'm sorry if I wasn't clear enough. I > would need something like this: > > # foo.rb > module Foo > def method_a > end > > def method_b > end > end > > # bar.rb > > def load_module > load "foo.rb" > puts Foo.methods > end > # `Foo' isn't known anymore Your example is not quite right. $ cat foo.rb module Foo def method_a end def method_b end end $ cat bar.rb def load_module load "foo.rb" puts Foo.instance_methods end load_module $ ruby bar.rb method_a method_b