Class: BackgroundWorker::WorkerExecution

Inherits:
Object
  • Object
show all
Defined in:
lib/background_worker/worker_execution.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(worker, method_name, options) ⇒ WorkerExecution

Returns a new instance of WorkerExecution.



5
6
7
8
9
10
# File 'lib/background_worker/worker_execution.rb', line 5

def initialize(worker, method_name, options)
  fail ArgumentError, "'uid' is required to identify worker" unless options[:uid].present?
  @worker = worker
  @method_name = method_name
  @options = options
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



3
4
5
# File 'lib/background_worker/worker_execution.rb', line 3

def method_name
  @method_name
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/background_worker/worker_execution.rb', line 3

def options
  @options
end

#workerObject (readonly)

Returns the value of attribute worker.



3
4
5
# File 'lib/background_worker/worker_execution.rb', line 3

def worker
  @worker
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/background_worker/worker_execution.rb', line 12

def call
  worker.send(method_name, options)
  report_implicitly_successful unless completed?

rescue StandardError => e
  log_worker_error(e)
  BackgroundWorker.after_exception(e)

ensure
  log_worker_finality
end