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

#initialize

Constructor Details

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

Class Method Details

.call(options, props) ⇒ Object

def self.call(options, props)

instance = options[:callback_class_name].constantize.new(props)
options[:callback_names].each { |method_name| instance.method(method_name).call }

end



18
19
20
21
22
23
24
25
26
# File 'lib/operationable/runners/serial.rb', line 18

def self.call(options, props)
  instance = options[:callback_class_name].constantize.new(props)

  options[:callback_names].each do |method_name|
    ::Operationable::Persister.around_call(options[:op_id], method_name, -> {
      instance.method(method_name).call
    })
  end
end

Instance Method Details

#optionsObject



28
29
30
31
32
33
34
# File 'lib/operationable/runners/serial.rb', line 28

def options
  { type: 'serial',
    callback_class_name: callback_class_name,
    callback_names: callback_names,
    queue: queue,
    op_id: persist_operation.id }
end

#processObject



9
10
11
# File 'lib/operationable/runners/serial.rb', line 9

def process
  (queue.blank? ? self.class : OperationJob.method(perform_method)).call(options, props)
end

#runObject



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

def run
  process
end