Class: TestTrack::ThreadedVisitorNotifier

Inherits:
Object
  • Object
show all
Defined in:
app/models/test_track/threaded_visitor_notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(visitor) ⇒ ThreadedVisitorNotifier

Returns a new instance of ThreadedVisitorNotifier.



4
5
6
# File 'app/models/test_track/threaded_visitor_notifier.rb', line 4

def initialize(visitor)
  @visitor = visitor
end

Instance Attribute Details

#visitorObject (readonly)

Returns the value of attribute visitor.



2
3
4
# File 'app/models/test_track/threaded_visitor_notifier.rb', line 2

def visitor
  @visitor
end

Instance Method Details

#notifyObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/test_track/threaded_visitor_notifier.rb', line 8

def notify
  payload = {
    visitor_id: visitor.id,
    assignments: visitor.unsynced_assignments
  }
  ActiveSupport::Notifications.instrument('test_track.notify_unsynced_assignments', payload) do
    new_thread_with_request_store do
      TestTrack::UnsyncedAssignmentsNotifier.new(payload).notify
    end
  end
end