Class CouchRest::ExtendedDocument
In: lib/couchrest/more/extended_document.rb
Parent: Document

Same as CouchRest::Document but with properties and validations

Methods

Included Modules

CouchRest::Callbacks CouchRest::Mixins::DocumentQueries CouchRest::Mixins::Views CouchRest::Mixins::DesignDoc CouchRest::Mixins::ExtendedAttachments CouchRest::Mixins::ClassProxy CouchRest::Mixins::Collection

External Aliases

new_document? -> new_record?
  for compatibility with old-school frameworks

Attributes

casted_by  [RW]  Accessors

Public Class methods

Defines an instance and save it directly to the database

Returns

 returns the reloaded document

Defines an instance and save it directly to the database

Returns

 returns the reloaded document or raises an exception

Temp solution to make the view_by methods available

Automatically set updated_at and created_at fields on the document whenever saving occurs. CouchRest uses a pretty decent time format by default. See Time#to_json

Name a method that will be called before the document is first saved, which returns a string to be used for the document‘s _id. Because CouchDB enforces a constraint that each id must be unique, this can be used to enforce eg: uniq usernames. Note that this id must be globally unique across all document types which share a database, so if you‘d like to scope uniqueness to this class, you should use the class name as part of the unique id.

Public Instance methods

Trigger the callbacks (before, after, around) and create the document It‘s important to have a create callback since you can‘t check if a document was new after you saved it

When creating a document, both the create and the save callbacks will be triggered.

Creates the document in the db. Raises an exception if the document is not created properly.

unlike save, create returns the newly created document

Deletes the document from the database. Runs the :destroy callbacks. Removes the _id and _rev fields, preparing the document to be saved to a new _id.

Returns the Class properties

Returns

Array:the list of properties for the instance

Trigger the callbacks (before, after, around) and save the document

Saves the document to the db using save. Raises an exception if the document is not saved properly.

Overridden to set the unique ID. Returns a boolean value

Trigger the callbacks (before, after, around) only if the document isn‘t new

Takes a hash as argument, and applies the values by using writer methods for each key. Raises a NoMethodError if the corresponding methods are missing. In case of error, no attributes are changed.

Takes a hash as argument, and applies the values by using writer methods for each key. It doesn‘t save the document at the end. Raises a NoMethodError if the corresponding methods are missing. In case of error, no attributes are changed.

[Validate]