[Nitro] Og questions

zimba-tm zimba.tm at gmail.com
Fri Aug 5 10:40:50 EDT 2005


Hello,

I have some stupid questions to ask about Og's functionning. I'm
really a newbie, and thus I'd understand that you don't loose your
time. But I'm also really excited and like to ask anyway.

 - Why do I have to tell the relations to Og ?
I've read that active-record uses a dictionnary to find singular and
plural terms. I'm wondering if it could be used to tell the relations
so that

def Post
  has_many :comments, Comment
end

def Comments
  belongs_to :post, Post
end

could become

def Post
  property :comments, Comment
end

def Comment
  property :post, Post
end

 - Is it possible to define customized data types and also can they
encapsulate validation ?
Depending of the field of application, you often have a set of data
types that you find everywhere. Typically in web forms. You'll have
the Password, the Country, the Email. Those types also have the same
validation rules all over the place. Maybe something like that :

def Email < String
  validate_value
  validate_length :range => 2..100, :msg_long => 'argh'
  validate_format :format => /[mysterious_regexp]/, :msg => 'wrong format'
end

def Author
  property :email, Email
end

a = Author.new
a.email = "user at tld.com"
a.email.valid? => true


That's all for today :-P

-- 
Cheers,
  zimba

http://zimba.oree.ch




More information about the Nitro-general mailing list