Module: ActsAsTracked::Tracking

Extended by:
ActiveSupport::Concern
Defined in:
lib/acts_as_tracked/tracking.rb

Instance Method Summary collapse

Instance Method Details

#activitiesObject



23
24
25
26
27
# File 'lib/acts_as_tracked/tracking.rb', line 23

def activities
  t = Activity.arel_table
  Activity.where t[:subject_type].eq(self.class.name).and(t[:subject_id].eq(id))
                                 .or(t[:parent_type].eq(self.class.name).and(t[:parent_id].eq(id)))
end

#activity_attributesObject



42
43
44
# File 'lib/acts_as_tracked/tracking.rb', line 42

def activity_attributes
  self.class.__global_activity_attributes.merge(@activity_attributes || {})
end

#activity_labelObject

Raises:

  • (NotImplementedError)


46
47
48
# File 'lib/acts_as_tracked/tracking.rb', line 46

def activity_label
  raise NotImplementedError, "You must define this method in #{self.class}"
end

#tracking_changes(attributes) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/acts_as_tracked/tracking.rb', line 29

def tracking_changes(attributes)
  @activity_attributes = attributes
  @tracking_changes = true
  yield
ensure
  @activity_attributes = {}
  @tracking_changes = false
end

#tracking_changes?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/acts_as_tracked/tracking.rb', line 38

def tracking_changes?
  @tracking_changes || self.class.__global_tracking_changes
end