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, options) ⇒ WorkerExecution

Returns a new instance of WorkerExecution.



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

def initialize(worker, options)
  @worker = worker
  @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



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

def call
  worker.perform_now(options)
  report_implicitly_successful unless completed?

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

ensure
  log_worker_finality
end