[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Creating objects from a template

e

2/12/2005 7:03:00 AM

> Lähettäjä: nobu.nokada@softhome.net
> Aihe: Re: Creating objects from a template
>
> Hi,
>
> At Sat, 12 Feb 2005 13:16:23 +0900,
> E S wrote in [ruby-talk:130578]:
> > > my_new_unit = types["Panzer"].new.extend(Unit) # As later
> >
> > I thought #extend only works for instance methods, not variables?
>
> extend_object module method will be called.
>
> module Unit
> def self.extend_object(obj)
> super
> obj._unit_initialize
> end
> end

Yep, sure enough it seems to work (which is obviously a very good
thing)! I'm relying on ruby-doc.org from work and looks like the
source doc they're using is outdated/incorrect/inaccurate:

obj.extend:
Adds to obj the instance methods from each module given as a
parameter.

mod.extend_object:
Extends the specified object by adding this module?s constants and
methods (which are added as singleton methods).

> --
> Nobu Nakada

Thanks!

E