Module | PaperTrail::Model::InstanceMethods |
In: |
lib/paper_trail/has_paper_trail.rb
|
Wrap the following methods in a module so we can include them only in the ActiveRecord models that declare `has_paper_trail`.
new_record? | -> | old_new_record? |
present? | -> | new_record? |
old_new_record? | -> | new_record? |
Invoked after rollbacks to ensure versions records are not created for changes that never actually took place
Returns true if this instance is the current, live one; returns false if this instance came from a previous version.
Returns the object (not a Version) as it became next. NOTE: if self (the item) was not reified from a version, i.e. it is the
"live" item, we return nil. Perhaps we should return self instead?
Mimics the `touch` method from `ActiveRecord::Persistence`, but also creates a version. A version is created regardless of options such as `:on`, `:if`, or `:unless`.
TODO: look into leveraging the `after_touch` callback from `ActiveRecord` to allow the regular `touch` method to generate a version as normal. May make sense to switch the `record_update` method to leverage an `after_update` callback anyways (likely for v4.0.0)
Returns the object (not a Version) as it was at the given timestamp.
Temporarily overwrites the value of whodunnit and then executes the provided block.