buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grotzke <martin.grot...@javakaffee.de>
Subject Re: How to define a task for all subprojects
Date Mon, 15 Jun 2009 11:55:30 GMT
On Sun, 2009-06-14 at 15:25 -0700, Alex Boisvert wrote:
> On Sun, Jun 14, 2009 at 2:52 PM, Martin Grotzke <
> martin.grotzke@javakaffee.de> 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

Mime
View raw message