module Sequel::Plugins::ActiveModel::InstanceMethods

def _save(opts)

in which this instance is created is rolled back.
For new objects, add a rollback checker to check if the transaction
def _save(opts)
  if new? && db.in_transaction?(opts)
    @rollback_checker = db.rollback_checker(opts)
  end
  super
end

def after_destroy

destroyed?
Record that an object was destroyed, for later use by
def after_destroy
  super
  @destroyed = true
end

def errors_class

Use ActiveModel compliant errors class.
def errors_class
  Errors
end

def model_name

Return ::ActiveModel::Name instance for the class.
def model_name
  model.model_name
end

def persisted?

False if the object is new? or has been destroyed, true otherwise.
def persisted?
  return false if new?
  return false if defined?(@destroyed)
  if defined?(@rollback_checker)
    if @rollback_checker.call
      return false
    end
  end
  
  true
end

def to_key

An array of primary key values, or nil if the object is not persisted.
def to_key
  if primary_key.is_a?(Symbol)
    [pk] if pk
  else
    pk if pk.all?
  end
end

def to_model

compliant, so this returns self.
With the active_model plugin, Sequel model objects are already
def to_model
  self
end

def to_param

primary keys, joins them with to_param_joiner.
An string representing the object's primary key. For composite
def to_param
  if persisted? and k = to_key
    k.join(to_param_joiner)
  end
end

def to_param_joiner

The string to use to join composite primary key param strings.
def to_param_joiner
  '-'
end

def to_partial_path

Returns a string identifying the path associated with the object.
def to_partial_path
  model._to_partial_path
end