Class: ActsAsTracked::Activity

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/acts_as_tracked/activity.rb

Instance Method Summary collapse

Instance Method Details

#human_changesObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/acts_as_tracked/activity.rb', line 17

def human_changes
  case activity_type
  when 'created'
    attribute_changes.reject { |_, values| values.last.to_s.blank? }
  when 'updated'
    attribute_changes.each { |_, values| values.map! { |v| v.presence || 'empty' } }
  when 'destroyed'
    attribute_changes.reject { |_, values| values.first.to_s.blank? }
  end
end

#parent_classObject



32
33
34
# File 'lib/acts_as_tracked/activity.rb', line 32

def parent_class
  @parent_class ||= parent_type&.constantize
end

#subject_classObject



28
29
30
# File 'lib/acts_as_tracked/activity.rb', line 28

def subject_class
  @subject_class ||= subject_type&.constantize
end