[Nitro] help with og!

itsme213 itsme213 at hotmail.com
Thu Nov 24 20:03:03 EST 2005


Thanks zimba!

Ok, so I will mechanically add some "property" to any og-classes (at least 
until I figure out a better way :)

Now having done:

class A
  property :name, String
end

class B
  property :name, String
  has_many :as, A
end

I expected to see some instance methods for :as added to B. However 
(B.instance_methods - Object.instance_methods) does not show any of these. 
So then I figure, maybe these relation-things are store-specific. So I added 
the Og.setup(...) and viola ... instance methods.

Next challenge ... I was hoping the kind of collection I got back from
  b.as

(an Og::HasManyCollection) would allow me to do natural collection-like 
things:
  b.as.each {|a| puts a.name}

But that outputs nothing. Not even a method_missing exception. Any ideas?


----- Original Message ----- 
From: "zimba-tm" <zimba.tm at gmail.com>
To: "General discussion about Nitro" <nitro-general at rubyforge.org>
Sent: Thursday, November 24, 2005 5:13 PM
Subject: Re: [Nitro] help with og!


> Hi,
>
> Og relies on the property method to "enchant" a class and store it. I
> guess there is another more elegant way to do it, but I don't know it.
> I help this will be a help for you to start.
>
> Example :
> =========
> class A
> end
>
> class B
>  property :name, String
>  has_many :as, A
> end
> =========
>
> This should work.
>
> On 24/11/05, itsme213 <itsme213 at hotmail.com> wrote:
>> aaargh!
>>
>> og looks very promising, but i am very frustrated at even getting 
>> started.
>>
>>
>> -----------
>> require 'og'
>>
>> class A
>> end
>>
>> class B
>>  has_many :as, A
>> end
>>
>>
>> #=> error: undefined method `has_many' for B:Class (NoMethodError)
>> Process ruby exited with code 1
>>
>> -----------
>> require 'og'
>>
>> class A
>> end
>>
>> class B
>>  property :a, A
>>  has_many :as, A
>> end
>>
>>
>> #=> no error
>>
>> -----------
>>
>> What on earth is going on?
>>
>> perhaps i am doing something very dumb, but have no idea where to look.
>>
>> maybe rdoc will help, but i can't even see or build any rdocs.
>>
>> help!!



More information about the Nitro-general mailing list