Sha256: 497ecf4d1d77653dddd21c2df8e3cf766ecd59e8a7be1ce32199893a04b34e62

Contents?: true

Size: 730 Bytes

Versions: 11

Compression:

Stored size: 730 Bytes

Contents

class TestTrack::ThreadedVisitorNotifier
  attr_reader :visitor

  def initialize(visitor)
    @visitor = visitor
  end

  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

  private

  def new_thread_with_request_store
    Thread.new(RequestStore.store) do |original_store|
      RequestStore.begin!
      RequestStore.store.merge!(original_store)
      yield
    ensure
      RequestStore.end!
      RequestStore.clear!
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
test_track_rails_client-7.1.2 app/models/test_track/threaded_visitor_notifier.rb
test_track_rails_client-7.1.1 app/models/test_track/threaded_visitor_notifier.rb
test_track_rails_client-7.0.0 app/models/test_track/threaded_visitor_notifier.rb
test_track_rails_client-6.0.0 app/models/test_track/threaded_visitor_notifier.rb
test_track_rails_client-5.0.1 app/models/test_track/threaded_visitor_notifier.rb
test_track_rails_client-5.0.0 app/models/test_track/threaded_visitor_notifier.rb
test_track_rails_client-4.0.2 app/models/test_track/threaded_visitor_notifier.rb
test_track_rails_client-4.0.1 app/models/test_track/threaded_visitor_notifier.rb
test_track_rails_client-4.0.0 app/models/test_track/threaded_visitor_notifier.rb
test_track_rails_client-4.0.0.rc3 app/models/test_track/threaded_visitor_notifier.rb
test_track_rails_client-4.0.0.rc2 app/models/test_track/threaded_visitor_notifier.rb