[Nitro] A few questions
George Moschovitis
george.moschovitis at gmail.com
Tue Jun 21 03:03:50 EDT 2005
Nicely said, I 'll add your answer to the wiki (if you have any
problem with this, remove it!)
-g.
On 6/21/05, Aleksi Niemela <Aleksi.Niemela at cs.helsinki.fi> wrote:
> David Corbin wrote:
>
> >>>3) Is there something magical about 'db', or does the Database object
> >>>effectively act like a singleton? How does the object know it's bound to
> >>>'db'?
> >>>
> >>>
> >>there is nothing special with db, you can use any variable name you want.
> >>
> >>
> >
> >I don't see where (in the tutorial), the classes are linked to a particular
> >database.
> >
> >
> Classes which will be managed get binding to certain database (ie.
> manager which contains a store representing that database) in this
> sequence of events:
>
> 1) class definition with Og keyword "property" or something alike in it
> (like class A; property :name, String; end)
> 1.1) that triggers Og meta programming which in turn adds methods like
> A#name, A#name=, A#find, ...
> 2) call to Og.setup (at the end of manager.rb)
> 2.1) which in turn calls in turn Manager#manage_classes which
> 2.2) manages either given classses or ones it finds through
> manageable_classes
> 2.3) which "knows" a class is a managed if it contains attribute __props
> (and is not empty)
> 3) and "managing a class" means
> 3.1) it will be added a comparator method
> 3.2) and ogmanager will be set for database given for Og.setup
> 3.3) it's relations to other classes will be enchanted (ie. has_many
> :article, Article will convert to Klass#articles method etc)
>
> Basically the answer to your question is point 2.3, the database object
> knows which classes to manage by checking for attribute __props. And a
> class knows to which database it should be saved through it's attribute
> ogmanager which contains datastore facing database.
>
> - Aleksi
>
> _______________________________________________
> 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