[extended-document] added support for property :name, :default => 'Matt" and default couchrest type
This commit is contained in:
parent
890b60cae4
commit
fa7b176fce
5 changed files with 63 additions and 6 deletions
|
@ -14,8 +14,8 @@ module CouchRest
|
|||
# Same as CouchRest::Document but with properties and validations
|
||||
class ExtendedDocument < Document
|
||||
include CouchRest::Callbacks
|
||||
include CouchRest::Mixins::DocumentProperties
|
||||
include CouchRest::Mixins::DocumentQueries
|
||||
include CouchRest::Mixins::DocumentProperties
|
||||
include CouchRest::Mixins::Views
|
||||
include CouchRest::Mixins::DesignDoc
|
||||
|
||||
|
@ -23,6 +23,16 @@ module CouchRest
|
|||
define_callbacks :save
|
||||
define_callbacks :destroy
|
||||
|
||||
def initialize(keys={})
|
||||
super
|
||||
apply_defaults # defined in CouchRest::Mixins::DocumentProperties
|
||||
# cast_keys
|
||||
unless self['_id'] && self['_rev']
|
||||
self['couchrest-type'] = self.class.to_s
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Automatically set <tt>updated_at</tt> and <tt>created_at</tt> fields
|
||||
# on the document whenever saving occurs. CouchRest uses a pretty
|
||||
# decent time format by default. See Time#to_json
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue