module Sequel::Plugins::ActiveModel::InstanceMethods

  1. lib/sequel/plugins/active_model.rb
Parent: ActiveModel

Constants

DEFAULT_TO_PARAM_JOINER = '-'.freeze  

The default string to join composite primary keys with in to_param.

Public Instance methods

after_destroy ()

Record that an object was destroyed, for later use by destroyed?

[show source]
# File lib/sequel/plugins/active_model.rb, line 42
def after_destroy
  super
  @destroyed = true
end
persisted? ()

False if the object is new? or has been destroyed, true otherwise.

[show source]
# File lib/sequel/plugins/active_model.rb, line 48
def persisted?
  !new? && @destroyed != true
end
to_key ()

An array of primary key values, or nil if the object is not persisted.

[show source]
# File lib/sequel/plugins/active_model.rb, line 53
def to_key
  if primary_key.is_a?(Symbol)
    [pk] if pk
  else
    pk if pk.all?
  end
end
to_model ()

With the ActiveModel plugin, Sequel model objects are already compliant, so this returns self.

[show source]
# File lib/sequel/plugins/active_model.rb, line 63
def to_model
  self
end
to_param ()

An string representing the object’s primary key. For composite primary keys, joins them with to_param_joiner.

[show source]
# File lib/sequel/plugins/active_model.rb, line 69
def to_param
  if persisted? and k = to_key
    k.join(to_param_joiner)
  end
end
to_partial_path ()

Returns a string identifying the path associated with the object.

[show source]
# File lib/sequel/plugins/active_model.rb, line 76
def to_partial_path
  model._to_partial_path
end