Sha256: cfeaf6482ef6df0dd8f20c9207afeff155d8289dab277e0f1c1116cf9a1cfa83
Contents?: true
Size: 685 Bytes
Versions: 22
Compression:
Stored size: 685 Bytes
Contents
module Spree class PromotionCodeBatch < ActiveRecord::Base class CantProcessStartedBatch < StandardError end belongs_to :promotion, class_name: "Spree::Promotion" has_many :promotion_codes, class_name: "Spree::PromotionCode", dependent: :destroy validates :number_of_codes, numericality: { greater_than: 0 } validates_presence_of :base_code, :number_of_codes def finished? state == "completed" end def process if state == "pending" update!(state: "processing") PromotionCodeBatchJob.perform_later(self) else raise CantProcessStartedBatch.new("Batch #{id} already started") end end end end
Version data entries
22 entries across 22 versions & 1 rubygems