module Userstamper::Stampable

Extends the stamping functionality of ActiveRecord by automatically recording the model responsible for creating, updating 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/userstamper/stampable.rb, line 83
def has_stamper?
  !self.class.stamper_class.nil? && !self.class.stamper_class.stamper.nil?
end
set_creator_attribute() click to toggle source
# File lib/userstamper/stampable.rb, line 87
def set_creator_attribute
  return unless has_stamper?

  creator_association = self.class.reflect_on_association(:creator)
  return unless creator_association
  return if creator.present?

  Userstamper::Utilities.assign_stamper(self, creator_association)
end
set_updater_attribute() click to toggle source
# File lib/userstamper/stampable.rb, line 97
def set_updater_attribute
  return unless has_stamper?

  updater_association = self.class.reflect_on_association(:updater)
  return unless updater_association
  return if !new_record? && !changed?

  Userstamper::Utilities.assign_stamper(self, updater_association)
end