Module CouchPotato::Persistence
In: lib/couch_potato/persistence/deep_tracked_property.rb
lib/couch_potato/persistence/type_caster.rb
lib/couch_potato/persistence/properties.rb
lib/couch_potato/persistence/active_model_compliance.rb
lib/couch_potato/persistence/revisions.rb
lib/couch_potato/persistence/callbacks.rb
lib/couch_potato/persistence/deep_dirty_attributes.rb
lib/couch_potato/persistence/json.rb
lib/couch_potato/persistence/dirty_attributes.rb
lib/couch_potato/persistence/simple_property.rb
lib/couch_potato/persistence.rb

Methods

[]   []=   attributes   attributes=   eql?   has_key?   hash   inherited   inspect   new   new?   new_record?   reload   to_param  

Classes and Modules

Module CouchPotato::Persistence::ActiveModelCompliance
Module CouchPotato::Persistence::Callbacks
Module CouchPotato::Persistence::DeepDirtyAttributes
Module CouchPotato::Persistence::DirtyAttributes
Module CouchPotato::Persistence::Json
Module CouchPotato::Persistence::Properties
Module CouchPotato::Persistence::PropertyMethods
Module CouchPotato::Persistence::Revisions
Class CouchPotato::Persistence::DeepTrackedProperty

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. the new model will be yielded to an optionally given block.

example:

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

  OR

  book = Book.new do |b|
    b.title = 'Time to Relax'
  end
  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 a reloaded instance. Does not touch the original instance.

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]