From: Michael Garriss Date: 2003-08-12T07:30:29+09:00 Subject: Re: newbie mixin questions Gennady wrote: >----- Original Message ----- >From: "Michael Garriss" >To: "ruby-talk ML" >Sent: Monday, August 11, 2003 3:16 PM >Subject: newbie mixin questions > > > > >>Hi, >> Just 2 questions: >> >>1) How can I mixin a class method (not an instance method)? >> >> > >class A > class << self > include SomeModule > end >end > > Very cool. Will this require me to have two seperate modules though? One for including class methods and the other of including the instance methods. > > >>2) How can I force a certain method to be called when the an object of a >>class that includes that module is initialized? Sort of like a mixin >>initialize.... >> >> > >module SomeModule > def new(*args) > object = super *args > # call whatever you want here > object > end >end > Again, very cool. If I include two modules into the same class, both with a #new, will one be over written? > > > >>TIA >>Michael Garriss >> >> >> >> >> > > > >