Class: DeliveryShipConfirmWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
app/workers/delivery_ship_confirm_worker.rb

Overview

Sidekiq worker: delivery ship confirm.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.lock_args(args) ⇒ Array

Note:

NormalizeArgsMiddleware ensures args are string-keyed before lock computation

Extract delivery_id for unique lock key

Parameters:

  • args (Array)

    the args to lock

Returns:

  • (Array)

    the resulting array of values



20
21
22
23
# File 'app/workers/delivery_ship_confirm_worker.rb', line 20

def self.lock_args(args)
  options = args.first || {}
  [options['delivery_id']]
end

Instance Method Details

#perform(options = {}) ⇒ Object

Note:

NormalizeArgsMiddleware converts to HashWithIndifferentAccess

Parameters:

  • options (Hash) (defaults to: {})

    Must include :delivery_id

Options Hash (options):

  • delivery_id (Integer)


28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/workers/delivery_ship_confirm_worker.rb', line 28

def perform(options = {})
  delivery_id = options[:delivery_id]

  @job_name = "Ship confirm for delivery id: #{delivery_id}"
  delivery = Delivery.find(delivery_id)
  if delivery.pending_ship_confirm?
    logger.info 'Delivery is pending ship confirm, calling delivery.individual_auto_ship_confirm'
    delivery.individual_auto_ship_confirm
    logger.info 'Finished auto ship confirm'
  else
    logger.info 'Delivery is not in ship confirm'
  end
end