Class: SpreeCmCommissioner::InventoryHolds::ReleaseJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- ApplicationJob
- SpreeCmCommissioner::InventoryHolds::ReleaseJob
- Defined in:
- app/jobs/spree_cm_commissioner/inventory_holds/release_job.rb
Overview
Primary release for :active holds. Scheduled at hold creation (wait_until: expires_at). Safety net: BulkReleaseStaleJob catches any active holds this job misses.
Instance Method Summary collapse
Methods included from ApplicationJobDecorator
handle_deserialization_error, prepended
Instance Method Details
#perform(options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/jobs/spree_cm_commissioner/inventory_holds/release_job.rb', line 8 def perform( = {}) hold = SpreeCmCommissioner::InventoryHold.find([:hold_id]) # Skip if already finalized (e.g. delayed or retried jobs). # The release service also enforces idempotency. return if hold.finalized? # When LockForPayment runs (triggered on payment creation), the hold transitions # to :payment_locked status. ReleaseJob must not touch those holds — # BulkReleaseStalePaymentLockedJob (cron) is the sole cleanup mechanism for them, # allowing future custom logic (e.g. extend instead of release when payments exist). return if hold.payment_locked? SpreeCmCommissioner::InventoryHolds::Release.call!( hold: hold, reason: :hold_expired, scheduled_release: true ) end |