Class: DeliveryShipConfirmWorker

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.lock_args(args) ⇒ Object

Extract delivery_id for unique lock key
Note: NormalizeArgsMiddleware ensures args are string-keyed before lock computation



15
16
17
18
# File 'app/workers/delivery_ship_confirm_worker.rb', line 15

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



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/workers/delivery_ship_confirm_worker.rb', line 22

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