Module: Locomotive::Concerns::ActivityService

Instance Method Summary collapse

Instance Method Details

#track_activity(key, options = {}) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
# File 'app/services/locomotive/concerns/activity_service.rb', line 5

def track_activity(key, options = {})
  return if @activity_disabled

  site = respond_to?(:site) ? self.site : options.delete(:site)

  if options[:actor].blank? && respond_to?(:account)
    options[:actor] = self.
  end

  site.activities.create! options.merge(key: key)
end

#without_tracking_activity(&block) ⇒ Object


17
18
19
20
21
22
# File 'app/services/locomotive/concerns/activity_service.rb', line 17

def without_tracking_activity(&block)
  @activity_disabled = true
  yield.tap do
    @activity_disabled = false
  end
end