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'
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