class PaperTrail::Events::Destroy

See docs in `Base`.

@api private

Public Instance Methods

data() click to toggle source

Return attributes of nascent `Version` record.

@api private

# File lib/mongo_trails/events/destroy.rb, line 14
def data
  data = {
    item_id: @record.id,
    item_type: @record.class.base_class.name,
    event: @record.paper_trail_event || "destroy",
    whodunnit: PaperTrail.request.whodunnit
  }
  if record_object?
    data[:object] = recordable_object(false)
  end
  if record_object_changes?
    data[:object_changes] = prepare_object_changes(notable_changes)
  end
  merge_item_subtype_into(data)
  merge_metadata_into(data)
end

Private Instance Methods

changes_in_latest_version() click to toggle source

Rails' implementation (eg. `@record.saved_changes`) returns nothing on destroy, so we have to build the hash we want.

@override

# File lib/mongo_trails/events/destroy.rb, line 37
def changes_in_latest_version
  @record.attributes.map { |attr, value| [attr, [value, nil]] }.to_h
end