Class: ActionTrace::ActivityLog
- Inherits:
-
Object
- Object
- ActionTrace::ActivityLog
- 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
-
#company ⇒ Object
readonly
Returns the value of attribute company.
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#occurred_at ⇒ Object
readonly
Returns the value of attribute occurred_at.
-
#paper_trail_version ⇒ Object
readonly
Returns the value of attribute paper_trail_version.
-
#raw_subject ⇒ Object
readonly
Returns the value of attribute raw_subject.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#trackable ⇒ Object
readonly
Returns the value of attribute trackable.
-
#trackable_type ⇒ Object
readonly
Returns the value of attribute trackable_type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #data_change? ⇒ Boolean
- #data_create? ⇒ Boolean
- #data_destroy? ⇒ Boolean
- #human_trackable_type ⇒ Object
-
#initialize(attributes = {}) ⇒ ActivityLog
constructor
A new instance of ActivityLog.
- #page_visit? ⇒ Boolean
- #session_start? ⇒ Boolean
Methods included from ActivityLogPresenter
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
#company ⇒ Object (readonly)
Returns the value of attribute company.
8 9 10 |
# File 'app/models/action_trace/activity_log.rb', line 8 def company @company end |
#details ⇒ Object (readonly)
Returns the value of attribute details.
8 9 10 |
# File 'app/models/action_trace/activity_log.rb', line 8 def details @details end |
#id ⇒ Object (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_at ⇒ Object (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_version ⇒ Object (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_subject ⇒ Object (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 |
#source ⇒ Object (readonly)
Returns the value of attribute source.
8 9 10 |
# File 'app/models/action_trace/activity_log.rb', line 8 def source @source end |
#trackable ⇒ Object (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_type ⇒ Object (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 |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'app/models/action_trace/activity_log.rb', line 8 def url @url end |
#user ⇒ Object (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
38 39 40 |
# File 'app/models/action_trace/activity_log.rb', line 38 def data_change? source == SOURCES[:data_change] end |
#data_create? ⇒ 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
42 43 44 |
# File 'app/models/action_trace/activity_log.rb', line 42 def data_destroy? source == SOURCES[:data_destroy] end |
#human_trackable_type ⇒ Object
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
46 47 48 |
# File 'app/models/action_trace/activity_log.rb', line 46 def page_visit? source == SOURCES[:page_visit] end |
#session_start? ⇒ Boolean
50 51 52 |
# File 'app/models/action_trace/activity_log.rb', line 50 def session_start? source == SOURCES[:session_start] end |