Module: SpreeCmCommissioner::IdempotentJob

Included in:
SpreeCmCommissioner::InventoryItems::BulkAdjustQuantitiesJob, SpreeCmCommissioner::InventoryItems::BulkAdjustQuantitiesOnHoldJob
Defined in:
app/jobs/concerns/spree_cm_commissioner/idempotent_job.rb

Instance Method Summary collapse

Instance Method Details

#default_idempotency_keyObject

Namespaced so the key is self-describing in the DB (no ‘source` column needed).



8
9
10
# File 'app/jobs/concerns/spree_cm_commissioner/idempotent_job.rb', line 8

def default_idempotency_key
  "#{self.class.name}:#{job_id}"
end

#with_idempotency(key = nil, &block) ⇒ Object



3
4
5
# File 'app/jobs/concerns/spree_cm_commissioner/idempotent_job.rb', line 3

def with_idempotency(key = nil, &block)
  SpreeCmCommissioner::IdempotencyKey.run_once(key.presence || default_idempotency_key, &block)
end