Class: Spree::PromotionCodeBatch

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

Defined Under Namespace

Classes: CantProcessStartedBatch

Instance Method Summary collapse

Instance Method Details

#finished?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/models/spree/promotion_code_batch.rb', line 12

def finished?
  state == "completed"
end

#processObject



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

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