From: Admin Tensor Date: 2011-11-25T03:13:45+09:00 Subject: How to Design Module Method? Hi, If I define a module method like this: module MyMod def MyMod.my_method end end then I can invoke it like this: irb> MyMod.my_method => nil but I cannot invoke my_method without the module name, even if I include the module: irb> include MyMod => Object irb> my_method NameError: undefined local variable or method `my_method' for main:Object Now, if I define the method like this: module MyMod def my_method end end then I cannot invoke my_method even with the module name: irb> MyMod.my_method NoMethodError: undefined method `my_method' for MyMod:Module but I can invoke it if I include the module: irb> include MyMod => Object irb> my_method => nil Therefore, my question is, is there any way so that both means of invoking work, i.e., for people who don't "include" the module they can type "MyMod.my_method", and for people who "include" the module they can simply type "my_method"? (I am using Ruby 1.9.2.) Regards, Bill -- Posted via http://www.ruby-forum.com/.