Module: Ddb::Userstamp::Stampable

Defined in:
lib/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:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/stampable.rb', line 21

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

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

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

    # Which class is responsible for stamping? Defaults to :user.
    class_inheritable_accessor  :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_inheritable_accessor  :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_inheritable_accessor  :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_inheritable_accessor  :deleter_attribute

    self.stampable
  end
end