From: Gennady Date: 2003-08-12T08:25:14+09:00 Subject: Re: newbie mixin questions ----- Original Message ----- From: "Michael Garriss" To: "ruby-talk ML" Sent: Monday, August 11, 2003 4:04 PM Subject: Re: newbie mixin questions > > > Thank you for the explanation. I'm still a bit confused about something > though: > > module Example > def method_I_want_to_be_a_class_method > # whatever > end > def mehtod_I_want_to_be_an_instance_method > # whatever > end > end > > class A > include Example > class << self > include Example > end > end > > How do I seperate the class methods from the instance methods in the > module? In my above code I'll have one extra unwanted class and one > extra unwanted instance method. If you really want to separate them, well, make them separate modules. From within the module methods you can check what method, class or instance, is being called: module SomeModule def some_method if self.class == Class puts "some_method: called as a class method" else puts "some_method: called as an instance method" end end end class A class << self include SomeMethod end include SomeMethod end A.some_method some_method: called as a class method A.new.some_method some_method: called as an instance method Gennady. > > Michael > > >