Sha256: d83e65ccb532a0b2d7ad251f5f8bf77b05054c88d3c22d06efb63d4a84c2a53a

Contents?: true

Size: 829 Bytes

Versions: 2

Compression:

Stored size: 829 Bytes

Contents

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

        if Spree.user_class
          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'
        else
          belongs_to :user
          has_and_belongs_to_many :users, join_table: 'spree_promotion_rules_users', foreign_key: 'promotion_rule_id'
        end

        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

2 entries across 2 versions & 1 rubygems

Version Path
spree_core-2.0.6 app/models/spree/promotion/rules/user.rb
spree_core-2.0.5 app/models/spree/promotion/rules/user.rb