[Nitro] Re: Og scaffolding

Michael Neumann mneumann at ntecs.de
Thu Feb 24 03:47:37 EST 2005

I CCed to nitro at .

George Moschovitis wrote:
> Here you are,
> class Article
>   property :name, String
>   property :age, Fixnum
>   has_many :comments, Comment 
> end

BTW, have you tried this:

class Article
   has_many :comments, Comment
   property :name, String
   property :age, Fixnum

The last time I tried it, it did not worked due to method #has_many not 
being declared. Would be nice if you could fix this.

> class Comment
>   property :text, String
>   belongs_to :article, Article 
> end
> par = Article.properties_and_relations
> =>
> [Property(:name), Property(:age), Og::HasMany(:comments)]

Why not Og::Property ?

> par[0].klass 
> => String
> par = Comment.properties_and_relations
> =>
> [Property(:text), Og::BelongsTo(:article), Property(:article_oid)]

Hm, this shows :article_oid, which is IMO part of the belongs_to 
relation. I don't like this! I don't want to know every database column, 
only those properties and relations specified by the user (otherwise you 
should show :oid, too, but then, how would I distinugish between 
properties where the user can enter something, and automatically created 
properties, used for example for the relations).

> par[1].property 
> => :article_oid

I'd expect something like:

class Attribute
   attr_reader :name
   attr_reader :klass # or type
   attr_reader :meta

class Property < Attribute

class BelongsTo < Attribute
   alias foreign_klass klass

class HasMany < Attribute
   alias foreign_klass klass


Does this make sense?



More information about the Nitro-general mailing list