Module: ActivityTracker::InstanceMethods

Defined in:
lib/activity_tracker/activity_tracker.rb

Instance Method Summary collapse

Instance Method Details

#create_activity_from_selfObject



56
57
58
59
60
61
62
63
# File 'lib/activity_tracker/activity_tracker.rb', line 56

def create_activity_from_self
  activity = Activity.new
  activity.item = self
  activity.action = self.class.to_s.underscore
  actor_id = self.send( activity_options[:actor].to_s + "_id" )
  activity.user_id = actor_id
  activity.save
end

#track_activity(action) ⇒ Object



65
66
67
68
69
70
71
72
73
74
# File 'lib/activity_tracker/activity_tracker.rb', line 65

def track_activity(action)
  if activity_options[:actions].include?(action)
    activity = Activity.new
    activity.action = action.to_s
    activity.user_id = self.id
    activity.save!
  else
    raise "The action #{action} can't be tracked."
  end
end