Module: Frigate::Operation::Worker::ClassMethods

Defined in:
lib/frigate/operation/worker.rb

Overview

Class methods of class that includes Worker module

Instance Method Summary collapse

Instance Method Details

#is_background?Boolean

Whether or not operation is background

Returns:

  • either background or not



23
24
25
26
# File 'lib/frigate/operation/worker.rb', line 23

def is_background?
  !(Rails.env.test? || Rails.env.cucumber?) ||
    (!ENV['FRIGATE_WORKER'].nil? || ENV['FRIGATE_WORKER'].downcase == 'true')
end

#run(params, options = {}) ⇒ Object

Overrides standard run method in order to run an operation as a background job

Parameters:

  • (defaults to: {})


16
17
18
19
# File 'lib/frigate/operation/worker.rb', line 16

def run(params, options = {})
  serialized_params = serialize_params(params)
  is_background? ? perform_async(serialized_params) : new.perform(serialized_params)
end