Module: PaperTrail::InstanceMethods

Defined in:
lib/paper_trail/has_paper_trail.rb

Instance Method Summary collapse

Instance Method Details

#record_createObject



33
34
35
36
# File 'lib/paper_trail/has_paper_trail.rb', line 33

def record_create
  versions.create(:event     => 'create',
                  :whodunnit => PaperTrail.whodunnit) if self.class.paper_trail_active
end

#record_destroyObject



46
47
48
49
50
# File 'lib/paper_trail/has_paper_trail.rb', line 46

def record_destroy
  versions.create(:event     => 'destroy',
                  :object    => object_to_string(previous_version),
                  :whodunnit => PaperTrail.whodunnit) if self.class.paper_trail_active
end

#record_updateObject



38
39
40
41
42
43
44
# File 'lib/paper_trail/has_paper_trail.rb', line 38

def record_update
  if changed? and self.class.paper_trail_active
    versions.build :event     => 'update',
                   :object    => object_to_string(previous_version),
                   :whodunnit => PaperTrail.whodunnit
  end
end