From: Robert Klemme Date: 2003-08-12T20:23:31+09:00 Subject: Re: newbie mixin questions "Michael Garriss" schrieb im Newsbeitrag news:3F37F45B.8080002@earthlink.net... > dblack@superlink.net wrote: > > >One other technique that might be relevant is Module#included, which > >as I understand it is essentially a new name for append_features. (Is > >that accurate?) Here's a 1.8.0 example: > > > > module M > > def self.included(c) > > def c.something > > puts "I'm a class method!" > > end > > super > > end > > > > def another > > puts "I'm an instance method!" > > end > > end > > > >The inclusion now operates, with fairly clear separation, on both the > >class and the instances: > > > > class A; include M; end > > > > A.something > > A.new.another > > > > > >David > > > > > > > > That's what I needed. Thanks! But: you now have multiple something methods with the same definition. That's ugly. I'd prefer the approach to extend a class with M as shown in the other postings: > [matz:] > > class Bar > Bar.extend(Foo) > end [Gavin]: Alternatively class Bar extend Foo end Regards robert