On Sun, 2009-06-14 at 15:25 -0700, Alex Boisvert wrote: > On Sun, Jun 14, 2009 at 2:52 PM, Martin Grotzke < > [email protected]> wrote: > > > Just what I wonder: why is this Buildr::ant()? Isn't ant() an instance > > method of the Buildr::Ant module (according to [1])? > > > Yes, it is... and that's why you can't call it directly ;) > > In Ruby, modules have no instances. Instance methods are available only in > classes that mix-in the module. > > The reason why the ant() method is available in Buildr is because > > 1) the Buildr module includes the Ant module (see buildr/java/ant.rb) > > module Buildr > ... > include Ant > > > and 2) the Buildr module extends itself so it gets all the instance methods > of the modules it includes (see buildr/buildr.rb) > > # Methods defined in Buildr are both instance methods (e.g. when included in > Project) > # and class methods when invoked like Buildr.artifacts(). > module Buildr ; extend self ; end > > Nifty, eh? (I still do get confused by all this mixin stuff myself) Ok, thanx for this great explanation!
IMHO this should also go into some understanding-buildr documentation :) Cheers, Martin > > alex
signature.asc
Description: This is a digitally signed message part
