Module: Userstamp::Stampable

Defined in:
lib/userstamp/stampable.rb

Overview

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

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/userstamp/stampable.rb', line 6

def self.included(base) #:nodoc:
  super

  base.extend(ClassMethods)
  base.class_eval do
    include InstanceMethods

    # Should ActiveRecord record userstamps? Defaults to true.
    class_attribute :record_userstamp
    self.record_userstamp = true

    # Which class is responsible for stamping? Defaults to :user.
    class_attribute :stamper_class_name

    # What column should be used for the creator stamp?
    # Defaults to :creator_id when compatibility mode is off
    # Defaults to :created_by when compatibility mode is on
    class_attribute :creator_attribute

    # What column should be used for the updater stamp?
    # Defaults to :updater_id when compatibility mode is off
    # Defaults to :updated_by when compatibility mode is on
    class_attribute :updater_attribute

    # What column should be used for the deleter stamp?
    # Defaults to :deleter_id when compatibility mode is off
    # Defaults to :deleted_by when compatibility mode is on
    class_attribute :deleter_attribute
  end
end