From: Nit Khair Date: 2008-10-04T18:21:58+09:00 Subject: Re: module scope not clear to me Ragav Satish wrote: >> >> >> require 'common' >> include 'Common' >> class Prog < Application >> f = Obj.new >> g = Foo.new >> #... etc ... >> >> > Depends on where the module is included. If its included at the top > level (outside of another class/module) then it's mixed into the Object > class from which all other classes ultimately derive , so method lookup > on any object will always find it. > --Cheers > --Ragav Wow ! That said, earlier in the case i gave above is it at the top level? Because my situation was like this (before refactoring). There were 2 classes in my file, and the first did NOT find it. It had to use a reference of the second class to call the module methods. Let me explain: ==== common.rb contains: def printme end ==== prog.rb require 'common' include 'Common' class Datasource # saves reference to Prog in constructor def initialize (app) @main = app end printme # this failed. @main.printme # this works end class Prog < Application new Datasource(self) printme # works end if __FILE__ == $0 p = new Prog... p.run ... end == end of file Here, class Prog was able to refer to all Module methods, but class datasource could not and i had to pass a ref of Prog, so it could. -- Posted via http://www.ruby-forum.com/.