Class: PaperTrail::Events::Create Private

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

Instance Method Summary collapse

Methods inherited from Base

#changed_notably?, #initialize

Constructor Details

This class inherits a constructor from PaperTrail::Events::Base

Instance Method Details

#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.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/paper_trail/events/create.rb', line 14

def data
  data = {
    item: @record,
    event: @record.paper_trail_event || "create",
    whodunnit: PaperTrail.request.whodunnit
  }
  if @record.respond_to?(:updated_at)
    data[:created_at] = @record.updated_at
  end
  if record_object_changes? && changed_notably?
    changes = notable_changes
    data[:object_changes] = prepare_object_changes(changes)
  end
  merge_item_subtype_into(data)
  (data)
end