Class: ConsoleBuddy::OneOffJob

Inherits:
Object
  • Object
show all
Defined in:
lib/console_buddy/one_off_job.rb

Constant Summary collapse

SERVICE_TYPES =
[:sidekiq, :resque, :active_job, :inline].freeze

Class Method Summary collapse

Class Method Details

.define(&block) ⇒ Object



31
32
33
# File 'lib/console_buddy/one_off_job.rb', line 31

def define(&block)
  @block = block
end

.perform(*args) ⇒ Object



35
36
37
38
39
# File 'lib/console_buddy/one_off_job.rb', line 35

def perform(*args)
  return unless @block

  @block.call(*args)
end

.service_typeObject



19
20
21
22
23
24
# File 'lib/console_buddy/one_off_job.rb', line 19

def service_type
  return @service_type if defined?(@service_type)
  return ConsoleBuddy.one_off_job_service_type if ConsoleBuddy.one_off_job_service_type.present?

  :inline
end

.service_type=(type) ⇒ Object



26
27
28
29
# File 'lib/console_buddy/one_off_job.rb', line 26

def service_type=(type)
  raise InvalidJobServiceType, "Valid service types are #{SERVICE_TYPES.join(', ')}" unless SERVICE_TYPES.include?(type)
  @service_type = type
end