buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Boisvert <boisv...@intalio.com>
Subject Re: How to define a task for all subprojects
Date Sun, 14 Jun 2009 22:25:16 GMT
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)

alex

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message