module ActiveRecord::Userstamp::Stampable

Extends the stamping functionality of ActiveRecord by automatically recording the model responsible for creating, updating, and deleting the current object. See the Stamper and ControllerAdditions modules for further documentation on how the entire process works.

Private Instance Methods

has_stamper?() click to toggle source
# File lib/active_record/userstamp/stampable.rb, line 93
def has_stamper?
  !self.class.stamper_class.nil? && !self.class.stamper_class.stamper.nil?
end
set_creator_attribute() click to toggle source
# File lib/active_record/userstamp/stampable.rb, line 97
def set_creator_attribute
  attribute = ActiveRecord::Userstamp.config.creator_attribute
  return if !has_stamper? || attribute.nil? || !has_attribute?(attribute)

  current_attribute_value = send(attribute)
  return if current_attribute_value.present?

  ActiveRecord::Userstamp::Utilities.assign_attribute(self, attribute)
end
set_deleter_attribute() click to toggle source
# File lib/active_record/userstamp/stampable.rb, line 116
def set_deleter_attribute
  attribute = ActiveRecord::Userstamp.config.deleter_attribute
  return if !has_stamper? || attribute.nil? || !has_attribute?(attribute)

  ActiveRecord::Userstamp::Utilities.assign_attribute(self, attribute)
  save
end
set_updater_attribute() click to toggle source
# File lib/active_record/userstamp/stampable.rb, line 107
def set_updater_attribute
  attribute = ActiveRecord::Userstamp.config.updater_attribute
  return if !has_stamper? || attribute.nil? || !has_attribute?(attribute)

  return if !self.new_record? && !self.changed?

  ActiveRecord::Userstamp::Utilities.assign_attribute(self, attribute)
end