From: Vincent Fourmond Date: 2006-09-27T18:08:29+09:00 Subject: Re: Modules, instance methods and class methods Hello ! > Not too long ago this was discussed with a length with Matz. The result > was #class_extension. > > module Base > def desc > return self.class.desc > end > > class_extension do > def desc > return @desc > end > end > end > > class ThisClass > include Base > end > > An excellent pure Ruby implementation of this was developed by Daniel > Schierbeck, It can be found it the Facets project > (facets.rubyforge.org). To use: require 'facet/module/class_extension'. > For convenience the code follows. Thanks ! > It remains to be seen if Matz ultimately goes with this approach in > Ruby 2.0. But as of yet I guess one could say it the most "official" > technique available. (Not to say that others are prefectly valid of > course) That would be cool if the syntax could be somewhat lighter: it somehow doesn't look right to me to have the code within a block. But that's just aesthetics... And that would be for ruby 2.0, if I understand right. Cheers ! Vince