Sha256: 12d51c65af0a93d7db450f5cc9824fc21c4333ad3a8d73e32573458fb6c820ce
Contents?: true
Size: 834 Bytes
Versions: 22
Compression:
Stored size: 834 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, lambda {|t| {:conditions => {: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
22 entries across 22 versions & 2 rubygems