Sha256: c43086e19b14a741af44dfac8423ade42829d4823c6f630b76dfbdddf9cedb2b
Contents?: true
Size: 625 Bytes
Versions: 5
Compression:
Stored size: 625 Bytes
Contents
# frozen_string_literal: true module SolidusPromotions class PromotionCodeBatch < Spree::Base class CantProcessStartedBatch < StandardError end belongs_to :promotion has_many :promotion_codes, dependent: :destroy validates :number_of_codes, numericality: { greater_than: 0 } validates :base_code, :number_of_codes, presence: true def finished? state == "completed" end def process raise CantProcessStartedBatch, "Batch #{id} already started" unless state == "pending" update!(state: "processing") PromotionCodeBatchJob.perform_later(self) end end end
Version data entries
5 entries across 5 versions & 1 rubygems