Module: PaperTrail::InstanceMethods

Defined in:
lib/paper_trail/has_paper_trail.rb

Instance Method Summary collapse

Instance Method Details

#record_createObject



44
45
46
47
48
# File 'lib/paper_trail/has_paper_trail.rb', line 44

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

#record_destroyObject



59
60
61
62
63
64
65
66
# File 'lib/paper_trail/has_paper_trail.rb', line 59

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

#record_updateObject



50
51
52
53
54
55
56
57
# File 'lib/paper_trail/has_paper_trail.rb', line 50

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