Class: PaperTrail::Events::Update Private

Inherits:
Base
  • Object
show all
Defined in:
lib/paper_trail/events/update.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.

See docs in ‘Base`.

Constant Summary

Constants inherited from Base

Base::E_FORBIDDEN_METADATA_KEY, Base::FORBIDDEN_METADATA_KEYS

Instance Method Summary collapse

Constructor Details

#initialize(record, in_after_callback, is_touch, force_changes) ⇒ Update

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.

  • is_touch - [boolean] - Used in the two situations that are touch-like:

    • ‘after_touch` we call `RecordTrail#record_update`

  • force_changes - [Hash] - Only used by ‘RecordTrail#update_columns`, because there dirty-tracking is off, so it has to track its own changes.



17
18
19
20
21
# File 'lib/paper_trail/events/update.rb', line 17

def initialize(record, in_after_callback, is_touch, force_changes)
  super(record, in_after_callback)
  @is_touch = is_touch
  @force_changes = force_changes
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.

If it is a touch event, and changed are empty, it is assumed to be implicit ‘touch` mutation, and will a version is created.

See github.com/rails/rails/commit/dcb825902d79d0f6baba956f7c6ec5767611353e

Returns:

  • (Boolean)


46
47
48
49
50
51
52
# File 'lib/paper_trail/events/update.rb', line 46

def changed_notably?
  if @is_touch && changes_in_latest_version.empty?
    true
  else
    super
  end
end

#dataObject

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.

Return attributes of nascent ‘Version` record.



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/paper_trail/events/update.rb', line 26

def data
  data = {
    item: @record,
    event: @record.paper_trail_event || "update",
    whodunnit: PaperTrail.request.whodunnit
  }
  if record_object?
    data[:object] = recordable_object(@is_touch)
  end
  merge_object_changes_into(data)
  merge_item_subtype_into(data)
  (data)
end