Class: Spree::PromotionCodeBatch

Inherits:
Base
  • Object
show all
Defined in:
app/models/spree/promotion_code_batch.rb

Defined Under Namespace

Classes: CantProcessStartedBatch

Instance Method Summary collapse

Methods inherited from Base

display_includes

Methods included from Core::Permalinks

#generate_permalink, #save_permalink

Instance Method Details

#finished?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/models/spree/promotion_code_batch.rb', line 14

def finished?
  state == "completed"
end

#processObject



18
19
20
21
22
23
24
25
# File 'app/models/spree/promotion_code_batch.rb', line 18

def process
  if state == "pending"
    update!(state: "processing")
    PromotionCodeBatchJob.perform_later(self)
  else
    raise CantProcessStartedBatch.new("Batch #{id} already started")
  end
end