Module CouchPotato::Persistence
In: lib/couch_potato/persistence.rb
lib/couch_potato/persistence/callbacks.rb
lib/couch_potato/persistence/dirty_attributes.rb
lib/couch_potato/persistence/json.rb
lib/couch_potato/persistence/properties.rb
lib/couch_potato/persistence/simple_property.rb
lib/couch_potato/persistence/validation.rb

Methods

Classes and Modules

Module CouchPotato::Persistence::Callbacks
Module CouchPotato::Persistence::DirtyAttributes
Module CouchPotato::Persistence::Json
Module CouchPotato::Persistence::Properties
Module CouchPotato::Persistence::Validation

Public Class methods

initialize a new instance of the model optionally passing it a hash of attributes. the attributes have to be declared using the property method

example:

  class Book
    include CouchPotato::Persistence
    property :title
  end
  book = Book.new :title => 'Time to Relax'
  book.title # => 'Time to Relax'

Public Instance methods

returns all of a model‘s attributes that have been defined using the property method as a Hash

example:

  class Book
    include CouchPotato::Persistence
    property :title
    property :year
  end
  book = Book.new :year => 2009
  book.attributes # => {:title => nil, :year => 2009}

assign multiple attributes at once. the attributes have to be declared using the property method

example:

  class Book
    include CouchPotato::Persistence
    property :title
    property :year
  end
  book = Book.new
  book.attributes = {:title => 'Time to Relax', :year => 2009}
  book.title # => 'Time to Relax'
  book.year # => 2009

returns true if a model hasn‘t been saved yet, false otherwise

new_record?()

Alias for new?

returns the document id this is used by rails to construct URLs can be overridden to for example use slugs for URLs instead if ids

[Validate]