Skip to content

Instantly share code, notes, and snippets.

@albertoleal
Created April 30, 2011 00:34
Show Gist options
  • Save albertoleal/949282 to your computer and use it in GitHub Desktop.
Save albertoleal/949282 to your computer and use it in GitHub Desktop.
Couch Rest model
=begin
shop = ShoppingCoupon.new(:name => 'Shop', :description =>"Clothes",
:items => [{:name => 'shirt', :price => 2.50}, {:name => 'pants', :price => 5}],
:purchased =>2011/03/21, :amount => 43.2)
shop.save
=end
class Items < Hash
include CouchRest::Model::CastedModel
property :name, String
property :price, Float
end
class ShoppingCoupon < CouchRest::Model::Base
use_database CouchServer.default_database
property :name, String
property :description, String
property :items, [Items]
property :purchased, DateTime
property :amount, Float
timestamps!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment