Class: Operationable::Runners::Serial

Inherits:
Base
  • Object
show all
Defined in:
lib/operationable/runners/serial.rb

Instance Attribute Summary

Attributes inherited from Base

#callbacks, #params, #record, #result, #user

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#check_status?, #ensure_enqueue, #initialize, #job_async_execute_method, #job_class, #job_sync_execute_method, #persist?, #store_callback

Methods included from Wrappable

#add_part, #callbacks, #inherited_callbacks, #new, #push_to_queue

Constructor Details

This class inherits a constructor from Operationable::Runners::Base

Class Method Details

.call(q_options:, props:) ⇒ Object



17
18
19
20
# File 'lib/operationable/runners/serial.rb', line 17

def self.call(q_options:, props:)
  instance = q_options[:callback_class_name].constantize.new(props, q_options)
  q_options[:callback_names].each { |method_name| instance.method(method_name).call }
end

Instance Method Details

#callback_namesObject



29
30
31
# File 'lib/operationable/runners/serial.rb', line 29

def callback_names
  check_callbacks.map { |callback| callback[:callback_method_name] }
end

#processObject



10
11
12
13
14
15
# File 'lib/operationable/runners/serial.rb', line 10

def process
  (queue.blank? ? self.class : perform(job_class_name)).call(
    q_options: q_options,
    props: props
  )
end

#q_optionsObject



22
23
24
25
26
27
# File 'lib/operationable/runners/serial.rb', line 22

def q_options
  store_callback({ type: 'serial',
    callback_class_name: callback_class_name,
    callback_names: callback_names,
    queue: queue })
end

#runObject



6
7
8
# File 'lib/operationable/runners/serial.rb', line 6

def run
  process
end