Sha256: bf2e81319a83de28b18d95facd7c36401d857ed40f45626795ad402e6890d548

Contents?: true

Size: 654 Bytes

Versions: 13

Compression:

Stored size: 654 Bytes

Contents

module Spree
  class Promotion
    module Rules
      class User < PromotionRule
        attr_accessible :user_ids_string

        belongs_to :user, :class_name => Spree.user_class.to_s
        has_and_belongs_to_many :users, :class_name => Spree.user_class.to_s, :join_table => 'spree_promotion_rules_users', :foreign_key => 'promotion_rule_id'

        def eligible?(order, options = {})
          users.none? or users.include?(order.user)
        end

        def user_ids_string
          user_ids.join(',')
        end

        def user_ids_string=(s)
          self.user_ids = s.to_s.split(',').map(&:strip)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
spree_promo-1.2.5 app/models/spree/promotion/rules/user.rb
spree_promo-1.2.4 app/models/spree/promotion/rules/user.rb
spree_promo-1.3.2 app/models/spree/promotion/rules/user.rb
spree_promo-1.2.3 app/models/spree/promotion/rules/user.rb
spree_promo-1.3.1 app/models/spree/promotion/rules/user.rb
spree_promo-1.3.0 app/models/spree/promotion/rules/user.rb
spree_promo-1.3.0.rc2 app/models/spree/promotion/rules/user.rb
dup_spree_promo-1.3.0.rc1 app/models/spree/promotion/rules/user.rb
spree_promo-1.3.0.rc1 app/models/spree/promotion/rules/user.rb
spree_promo-1.2.2 app/models/spree/promotion/rules/user.rb
spree_promo-1.2.0 app/models/spree/promotion/rules/user.rb
spree_promo-1.2.0.rc2 app/models/spree/promotion/rules/user.rb
spree_promo-1.2.0.rc1 app/models/spree/promotion/rules/user.rb