2009-05-12 00:17:53 +02:00
|
|
|
class Cat < CouchRest::ExtendedDocument
|
|
|
|
include ::CouchRest::Validation
|
|
|
|
|
|
|
|
# Set the default database to use
|
2009-05-28 03:16:50 +02:00
|
|
|
use_database DB
|
2009-05-12 00:17:53 +02:00
|
|
|
|
2009-10-31 13:40:32 +01:00
|
|
|
property :name, :accessible => true
|
|
|
|
property :toys, :cast_as => ['CatToy'], :default => [], :accessible => true
|
|
|
|
property :favorite_toy, :cast_as => 'CatToy', :accessible => true
|
|
|
|
property :number
|
2009-05-12 00:17:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
class CatToy < Hash
|
|
|
|
include ::CouchRest::CastedModel
|
|
|
|
include ::CouchRest::Validation
|
|
|
|
|
|
|
|
property :name
|
|
|
|
|
2009-10-30 19:07:59 +01:00
|
|
|
validates_presence_of :name
|
2009-05-12 00:17:53 +02:00
|
|
|
end
|