class Anachronic::BackgroundExecutor

Class for deciding a background execution backend

Public Class Methods

call(instance, method, *args) click to toggle source
# File lib/anachronic/background_executor.rb, line 12
def call(instance, method, *args)
  no_executor unless executor

  executor.call(instance, method, *args)
end

Private Class Methods

default_or_defined?(name) click to toggle source
# File lib/anachronic/background_executor.rb, line 28
def default_or_defined?(name)
  defined?(name.constantize) || config.default_executor.name == name
end
executor() click to toggle source
# File lib/anachronic/background_executor.rb, line 20
def executor
  @executor ||= begin
    return Anachronic::Executors::Sidekiq if defined?('Sidekiq')
    return Anachronic::Executors::ApplicationJob if defined?('ApplicationJob')
    return Anachronic::Executors::Resque if defined?('Resque')
  end
end
no_executor() click to toggle source
# File lib/anachronic/background_executor.rb, line 32
def no_executor
  raise Error('No background executor found')
end