From: 7stud -- Date: 2009-05-04T03:58:18+09:00 Subject: Re: modules and classes question Marcelo Barbudas wrote: > Hi, >> class Resource >> def Resource.meth >> puts "executing meth" >> end >> end >> >> end >> >> > Thanks for the answer. > > Resource has to call a function from Main, or return an error if Main > isn't initialized. > > I made Resource a subclass of Main because I wanted it to be the main > connection class. The next iteration of the code: module Library class Main @@ready_to_go = false def Main.initialize puts "initializing" @@ready_to_go = true end def Main.do_stuff if not @@ready_to_go raise "error" else puts "doing stuff" end end end class Resource def Resource.meth Main.do_stuff end end end Library::Main.initialize Library::Resource.meth --output:-- initializing doing stuff -- Posted via http://www.ruby-forum.com/.