Sha256: 9a4862d3c46b471d3fcfcb590cbc2d01c300f623b41f2e457ac23d57a568b93d

Contents?: true

Size: 639 Bytes

Versions: 9

Compression:

Stored size: 639 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.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

9 entries across 9 versions & 2 rubygems

Version Path
spree_promo-1.3.5 app/models/spree/promotion/rules/user.rb
spree_promo-1.3.4 app/models/spree/promotion/rules/user.rb
spree_core-2.0.4 app/models/spree/promotion/rules/user.rb
spree_promo-1.3.3 app/models/spree/promotion/rules/user.rb
spree_core-2.0.3 app/models/spree/promotion/rules/user.rb
spree_core-2.0.2 app/models/spree/promotion/rules/user.rb
spree_core-2.0.1 app/models/spree/promotion/rules/user.rb
spree_core-2.0.0 app/models/spree/promotion/rules/user.rb
spree_core-2.0.0.rc1 app/models/spree/promotion/rules/user.rb