Sha256: 76392962b71c3024834f5c3155ce6a8135209d9c011036c392692a6e5d962d42

Contents?: true

Size: 814 Bytes

Versions: 4

Compression:

Stored size: 814 Bytes

Contents

require 'makura'

# Setting up everything

# Makura::Model.server = 'http://localhost:5984'
Makura::Model.database = 'mydb'

class Post
  include Makura::Model

  properties :title, :text, :tags
  belongs_to :author

  layout :all

  validates(:title){ presence and length :within => (3..100) }
  validates(:text){ presence }

  save # submit design docs to CouchDB
end

class Author
  include Makura::Model

  property :name

  layout :posts, :reduce => :sum_length
  layout :all

  save
end

class Comment
  include Makura::Model

  property :text
end

# And here it goes.

author = Author.new('name' => 'Michael Fellinger')
author.save

post = Post.new(
  :title => 'Hello, World!',
  :text => 'This is my first post',
  :author => author)
post.save

Post.view(:all).each do |post|
  p post
  p post.author
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
careo-makura-0.1 example/blog.rb
careo-makura-2009.2.17 example/blog.rb
manveru-makura-2009.02.18 example/blog.rb
manveru-makura-2009.03.01 example/blog.rb