Class: PaperTrail::Events::Base Private
- Inherits:
-
Object
- Object
- PaperTrail::Events::Base
- Defined in:
- lib/paper_trail/events/base.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
We refer to times in the lifecycle of a record as "events". There are three events:
- create
after_createwe callRecordTrail#record_create
- update
after_updatewe callRecordTrail#record_updateafter_touchwe callRecordTrail#record_updateRecordTrail#save_with_versioncallsRecordTrail#record_updateRecordTrail#update_columnsis also referred to as an update, though it usesRecordTrail#record_update_columnsrather thanRecordTrail#record_update
- destroy
before_destroyorafter_destroywe callRecordTrail#record_destroy
The value inserted into the event column of the versions table can also
be overridden by the user, with paper_trail_event.
Constant Summary collapse
- E_FORBIDDEN_METADATA_KEY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
<<-EOS.squish Forbidden metadata key: %s. As of PT 14, the following metadata keys are forbidden: %s EOS
- FORBIDDEN_METADATA_KEYS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%i[ created_at id item_id item_subtype item_type updated_at ].freeze
Instance Method Summary collapse
-
#changed_notably? ⇒ Boolean
private
Determines whether it is appropriate to generate a new version instance.
-
#initialize(record, in_after_callback) ⇒ Base
constructor
private
A new instance of Base.
Constructor Details
#initialize(record, in_after_callback) ⇒ Base
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Base.
39 40 41 42 |
# File 'lib/paper_trail/events/base.rb', line 39 def initialize(record, in_after_callback) @record = record @in_after_callback = in_after_callback end |
Instance Method Details
#changed_notably? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determines whether it is appropriate to generate a new version
instance. A timestamp-only update (e.g. only updated_at changed) is
considered notable unless an ignored attribute was also changed.
49 50 51 52 53 54 55 56 |
# File 'lib/paper_trail/events/base.rb', line 49 def changed_notably? if ignored_attr_has_changed? = @record.send(:timestamp_attributes_for_update_in_model).map(&:to_s) (notably_changed - ).any? else notably_changed.any? end end |