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
|
|
|
|
|
|
|
property :name
|
|
|
|
property :toys, :cast_as => ['CatToy'], :default => []
|
2009-05-28 21:18:23 +02:00
|
|
|
property :favorite_toy, :cast_as => 'CatToy'
|
2009-05-12 00:17:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
class CatToy < Hash
|
|
|
|
include ::CouchRest::CastedModel
|
|
|
|
include ::CouchRest::Validation
|
|
|
|
|
|
|
|
property :name
|
|
|
|
|
|
|
|
validates_present :name
|
|
|
|
end
|