Sha256: 4f8e5589a8f6cef9acf80d9f89a2a9c55539776412c699499cb757ded99b0d21
Contents?: true
Size: 798 Bytes
Versions: 15
Compression:
Stored size: 798 Bytes
Contents
# Base class for all promotion rules module Spree class PromotionRule < ActiveRecord::Base belongs_to :promotion, foreign_key: 'activator_id', class_name: 'Spree::Promotion' scope :of_type, ->(t) { where(type: t) } validate :promotion, presence: true validate :unique_per_activator, on: :create attr_accessible :preferred_operator, :preferred_amount, :product, :product_ids_string, :preferred_match_policy def eligible?(order, options = {}) raise 'eligible? should be implemented in a sub-class of Promotion::PromotionRule' end private def unique_per_activator if Spree::PromotionRule.exists?(activator_id: activator_id, type: self.class.name) errors[:base] << "Promotion already contains this rule type" end end end end
Version data entries
15 entries across 15 versions & 1 rubygems