class Prospector::Background::Coordinator

Public Instance Methods

enqueue() click to toggle source
# File lib/prospector/background/coordinator.rb, line 3
def enqueue
  return unless Prospector.enabled?

  case adapter_name
  when :active_job then enqueue_via_active_job
  when :sidekiq then enqueue_via_sidekiq
  when :inline then perform_immediately
  when :none then return
  else
    raise UnsupportedAdapterError.new(adapter_name)
  end
end

Private Instance Methods

adapter_name() click to toggle source
# File lib/prospector/background/coordinator.rb, line 18
def adapter_name
  @adapter_name ||= Prospector.configuration.background_adapter
end
enqueue_via_active_job() click to toggle source
# File lib/prospector/background/coordinator.rb, line 22
def enqueue_via_active_job
  raise UnsupportedAdapterError unless Object.const_defined?('ActiveJob::Base')

  NotifyJob.perform_later
end
enqueue_via_sidekiq() click to toggle source
# File lib/prospector/background/coordinator.rb, line 28
def enqueue_via_sidekiq
  raise UnsupportedAdapterError unless Object.const_defined?('Sidekiq::Worker')

  NotifyWorker.perform_async
end
perform_immediately() click to toggle source
# File lib/prospector/background/coordinator.rb, line 34
def perform_immediately
  Prospector.notify!
end