[Nitro] Og reloaded, part 2, coming in 0.19.0

George Moschovitis george.moschovitis at gmail.com
Sun Jun 5 13:17:34 EDT 2005


Hmm, will investigate this :) 

Anyway in the latest development code you can do:

class Document
end

class Aritcle < Document
end

class Photo < Document
end

and then:

docs = Document.all
docs[0].class # -> Article
docs[1].class # -> Photo

or

photos = Photo.all (only selects photos) 


or 

category.documents # selects all document children

or 

category.documents(:type => Photo) # selects only photos

or

Document.metadata.subclasses # [Photo, Article]


etc etc...

This looks very cool (though I am saying it myself :-))

regards,
George.


On 6/5/05, Michael Neumann <mneumann at ntecs.de> wrote:
> Am Sunday 05 June 2005 09:16 schrieb George Moschovitis:
> > > Of course it can be implemented differently, e.g.
> > > storing the class/table name together with the oid attribute (this has
> > > the advantage that it doesn't break ordered sequences).
> >
> > hm, seems I am right, this looks like STI, as I said this is already
> > in for 0.19.0 and works orthogonally to the other features :)
> >
> > BTW, the current implementation stores the class name along with the
> > pk, I am wondering if storing a hash of the name is a better solution,
> > any comments?
> 
> Or you create an intermediate table called _og_classes, which defines a
> mapping from classname to a unique id (the pk of the table ;-). This would
> save memory and is probably faster (?) than using classnames directly.
> 
> Regards,
> 
>   Michael
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general
> 


-- 
http://nitro.rubyforge.org
http://www.joy.gr




More information about the Nitro-general mailing list