George Moschovitis
11/1/2004 1:42:00 PM
Here is a small example btw:
class Comment; end
class Article
has_many Comment, :comments
prop_accessor String, :title
prop_accessor String, :body
prop_accessor Hash, :options
def initialize(title = nil, body = nil)
@title = title
@body = body
@options = {"hello" => "world"}
end
end
class Comment
belongs_to Article, :article
prop_accessor String, :body
prop_accessor Time, :create_time
def initialize(body = nil)
@create_time = Time.now
@body = body
end
end
$og.manage_classes(Article, Comment)
article = Article.new("title", "the body")
article.save!
# lookup
article = Article[1]
article = $og.load(1, Article)
comment = Comment.new("the comment")
comment.article = article
comment.save!
# or
# $og << comment
# or
# Comment.save(comment)
p article.comments
The backend database and the schema for those objects
is created automatically.
have fun,
George Moschovitis