module Mince::Model::Persistence

Public Instance Methods

persisted?() click to toggle source

Returns true if the record indicates that it has been persisted to a data model. Returns false otherwise.

# File lib/mince/model/persistence.rb, line 28
def persisted?
  !!id
end
save() click to toggle source

Saves the object to the data model. Stores if new, updates previous entry if it has already been saved.

# File lib/mince/model/persistence.rb, line 34
def save
  ensure_no_extra_fields if self.respond_to?(:ensure_no_extra_fields, true)

  if persisted?
    data_model.update(self)
  else
    @id = data_model.store(self)
  end
end