-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sep 24, 2005, at 1:56 PM, Michael Roth wrote:
> I'm a little bit new to the wonderful world of ruby and have a small
> problem. I would like to mixin a module method:
>
>   module M
>     def M.foobar id
>       puts "Hello Ruby: #{id}"
>     end
>   end
>
>   class C
>     include M
>     foobar :example
>   end

module M
   def foobar id
     puts "Hello Ruby: #{id}"
   end
end

class C
   extend M
   foobar :example
end

OR if you'd like M to have both instance and class methods:

module M
   def self.included(base)
     super
     base.extend ClassMethods
   end

   def baz
     # ...
   end

   module ClassMethods
     def foobar id
       # ...
     end
   end
end

class C
   include M
   foobar :example
end

C.new.baz

Modules are pleasant little beasts.

Best,
jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFDNcDfAQHALep9HFYRAsQNAKCG5eMkzpBIjNkc0Tk4qDcMI/UEHQCg1HF2
rpdtYLov7fyKH9+SC24VU2c=
=4RK9
-----END PGP SIGNATURE-----