module ArtirixDataModels::Model::PrimaryKey

Constants

PARAM_JOIN_STRING

Public Instance Methods

primary_key() click to toggle source
# File lib/artirix_data_models/model.rb, line 286
def primary_key
  raise UndefinedPrimaryKeyAttributeError unless self.class.primary_key_attribute.present?
  send(self.class.primary_key_attribute)
end
set_primary_key(value) click to toggle source
# File lib/artirix_data_models/model.rb, line 291
def set_primary_key(value)
  raise UndefinedPrimaryKeyAttributeError unless self.class.primary_key_attribute.present?
  send("#{self.class.primary_key_attribute}=", value)
end
to_key() click to toggle source
# File lib/artirix_data_models/model.rb, line 307
def to_key
  # for ActiveModel compliant
  if persisted?
    [primary_key]
  else
    nil
  end
end
to_param() click to toggle source
# File lib/artirix_data_models/model.rb, line 298
def to_param
  # for ActiveModel compliant
  if persisted?
    to_key.join PARAM_JOIN_STRING
  else
    nil
  end
end