Class: ActionTrace::ActivityLog

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Translation
Includes:
ActivityLogPresenter
Defined in:
app/models/action_trace/activity_log.rb

Constant Summary collapse

SOURCES =
{
  data_create: 'data_create',
  data_change: 'data_change',
  data_destroy: 'data_destroy',
  page_visit: 'page_visit',
  session_start: 'session_start',
  session_end: 'session_end'
}.freeze

Constants included from ActivityLogPresenter

ActionTrace::ActivityLogPresenter::VISUAL_CONFIG

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ActivityLogPresenter

#color, #icon, #subject

Constructor Details

#initialize(attributes = {}) ⇒ ActivityLog

Returns a new instance of ActivityLog.



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/action_trace/activity_log.rb', line 20

def initialize(attributes = {})
  @id = attributes[:id]
  @source = attributes[:source]
  @occurred_at = attributes[:occurred_at]
  @user = attributes[:user]
  @raw_subject = attributes[:subject]
  @details = attributes[:details] || {}
  @url = attributes[:url]
  @paper_trail_version = attributes[:paper_trail_version]
  @trackable = attributes[:trackable]
  @trackable_type = attributes[:trackable_type]
  @company = attributes[:user]&.company if attributes[:user].respond_to?(:company)
end

Instance Attribute Details

#companyObject (readonly)

Returns the value of attribute company.



8
9
10
# File 'app/models/action_trace/activity_log.rb', line 8

def company
  @company
end

#detailsObject (readonly)

Returns the value of attribute details.



8
9
10
# File 'app/models/action_trace/activity_log.rb', line 8

def details
  @details
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'app/models/action_trace/activity_log.rb', line 8

def id
  @id
end

#occurred_atObject (readonly)

Returns the value of attribute occurred_at.



8
9
10
# File 'app/models/action_trace/activity_log.rb', line 8

def occurred_at
  @occurred_at
end

#paper_trail_versionObject (readonly)

Returns the value of attribute paper_trail_version.



8
9
10
# File 'app/models/action_trace/activity_log.rb', line 8

def paper_trail_version
  @paper_trail_version
end

#raw_subjectObject (readonly)

Returns the value of attribute raw_subject.



8
9
10
# File 'app/models/action_trace/activity_log.rb', line 8

def raw_subject
  @raw_subject
end

#sourceObject (readonly)

Returns the value of attribute source.



8
9
10
# File 'app/models/action_trace/activity_log.rb', line 8

def source
  @source
end

#trackableObject (readonly)

Returns the value of attribute trackable.



8
9
10
# File 'app/models/action_trace/activity_log.rb', line 8

def trackable
  @trackable
end

#trackable_typeObject (readonly)

Returns the value of attribute trackable_type.



8
9
10
# File 'app/models/action_trace/activity_log.rb', line 8

def trackable_type
  @trackable_type
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'app/models/action_trace/activity_log.rb', line 8

def url
  @url
end

#userObject (readonly)

Returns the value of attribute user.



8
9
10
# File 'app/models/action_trace/activity_log.rb', line 8

def user
  @user
end

Instance Method Details

#data_change?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/models/action_trace/activity_log.rb', line 38

def data_change?
  source == SOURCES[:data_change]
end

#data_create?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/models/action_trace/activity_log.rb', line 34

def data_create?
  source == SOURCES[:data_create]
end

#data_destroy?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/action_trace/activity_log.rb', line 42

def data_destroy?
  source == SOURCES[:data_destroy]
end

#human_trackable_typeObject



54
55
56
57
58
59
60
# File 'app/models/action_trace/activity_log.rb', line 54

def human_trackable_type
  return nil if trackable_type.blank?

  trackable_type.constantize.model_name.human
rescue StandardError
  trackable_type
end

#page_visit?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/models/action_trace/activity_log.rb', line 46

def page_visit?
  source == SOURCES[:page_visit]
end

#session_start?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'app/models/action_trace/activity_log.rb', line 50

def session_start?
  source == SOURCES[:session_start]
end