From: 7stud -- Date: 2009-05-04T04:25:23+09:00 Subject: Re: modules and classes question 7stud -- wrote: > Another iteration. Try this: module Library class BaseResource @@ready_to_go = false def BaseResource.initialize puts "initializing" @@ready_to_go = true end def do_stuff if not @@ready_to_go raise "error" else puts "doing stuff" end end end class SpecializedResource < BaseResource def SpecializedResource.meth do_stuff end end end Library::BaseResource.initialize Library::SpecializedResource.meth That doesn't work. When you write a method call without an object in front of it: class SpecializedResource < BaseResource def SpecializedResource.meth do_stuff #<-------**** end end the implicit caller is self. Inside meth, self is equal to the object that called meth. The object that called meth can be seen in this line: Library::SpecializedResource.meth It's the class Library::SpecializedResource. So inside meth, self is equal to the Library::SpecializedResource class. And the Library:SpecializedResource class does not have a method named do_stuff--only instances of that class have a method named do_stuff(which is inherited from BaseResource). To call the instance method, you need an instance. So you can do something like this: class SpecializedResource < BaseResource def SpecializedResource.meth sr = SpecializedResource.new sr.do_stuff end end -- Posted via http://www.ruby-forum.com/.