2009-05-11 17:17:53 -05:00
|
|
|
class Cat < CouchRest::ExtendedDocument
|
|
|
|
include ::CouchRest::Validation
|
|
|
|
|
|
|
|
# Set the default database to use
|
2009-05-27 18:16:50 -07:00
|
|
|
use_database DB
|
2009-05-11 17:17:53 -05:00
|
|
|
|
2009-10-31 10:40:32 -02: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-11 17:17:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
class CatToy < Hash
|
|
|
|
include ::CouchRest::CastedModel
|
|
|
|
include ::CouchRest::Validation
|
|
|
|
|
|
|
|
property :name
|
|
|
|
|
2009-10-30 16:07:59 -02:00
|
|
|
validates_presence_of :name
|
2009-05-11 17:17:53 -05:00
|
|
|
end
|