From: Robert Dober Date: 2007-07-24T21:00:04+09:00 Subject: Re: Inherited & load On 7/24/07, F. Senault wrote: > Le 24 juillet 2007 � 12:20, Robert Dober a �crit : > > > On 7/24/07, F. Senault wrote: > > >> Then, when I use Tester.load!, all the files in the specified path are > >> load'ed, and all the classes inheriting from Tester are registered as > >> plugins of that class, validated against the obligatory methods, and, > >> unless told otherwise, an instance of each is created and made available > >> and enumerable through an array. > > I do not see any particular reason why not to use Module inclusion; > > Instead of > > class Tester < Plugin > > class Tester > > include Plugin ## or maybe extend, I have not looked into the details > > end > > Now you can be sure that > > Plugin#included / Plugin#extended > > is executed evry time you load a file. > > Did I miss something? > > Oh yes of course might be a pain to redesign :(. > > Yup, basically, I didn't know I'd hit that problem with included, and it > *will* be a pain to redesign. > > OTOH, I can't manage to use included neither : > > #! /usr/local/bin/ruby > > module Plugin > def self.included(m) > puts "#{m} includes me." > end > end > > class TestA > include Plugin > end > class TestA1 < TestA ; end class TestA1 include Plugin But that will not do the trick, you need meta information on class level, I just have tried to adapt update.rb for usage with extend class Test extend Plugin class Test1 extend Plugin I will send the patch (err the new file the patch is longer ) off list. Maybe you want to consider its deployment maybe not, was fun reading your code and your ideas, thx 4 sharing. Cheers Robert -- I always knew that one day Smalltalk would replace Java. I just didn't know it would be called Ruby -- Kent Beck