Module: Interactor::SidekiqWorker

Defined in:
lib/interactor/sidekiq.rb

Overview

Defined Under Namespace

Classes: Worker

Instance Method Summary collapse

Instance Method Details

#async_call(context = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/interactor/sidekiq.rb', line 48

def async_call(context = {})
  options = handle_sidekiq_options(context)
  schedule_options = delay_sidekiq_schedule_options(context)

  Worker.set(options).perform_in(schedule_options.fetch(:delay, 0), handle_context_for_sidekiq(context))
  new(context.to_h).context
rescue Exception => e
  begin
    new(context.to_h).context.fail!(error: e.message)
  rescue Failure => e
    e.context
  end
end

#sync_call(context = {}) ⇒ Object



44
45
46
# File 'lib/interactor/sidekiq.rb', line 44

def sync_call(context = {})
  new(context).tap(&:run!).context
end