Sha256: 45b1fc3c6e05e8eaaba34aae33a844945239845b392f6b981fd793ce09c42ae9

Contents?: true

Size: 828 Bytes

Versions: 45

Compression:

Stored size: 828 Bytes

Contents

module Spree
  class Promotion
    module Rules
      class User < PromotionRule
        belongs_to :user, class_name: "::#{Spree.user_class}"

        has_many :promotion_rule_users, class_name: 'Spree::PromotionRuleUser',
                                        foreign_key: :promotion_rule_id,
                                        dependent: :destroy
        has_many :users, through: :promotion_rule_users, class_name: "::#{Spree.user_class}"

        def applicable?(promotable)
          promotable.is_a?(Spree::Order)
        end

        def eligible?(order, _options = {})
          users.include?(order.user)
        end

        def user_ids_string
          user_ids.join(',')
        end

        def user_ids_string=(s)
          # check this
          self.user_ids = s
        end
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
spree_core-4.6.0 app/models/spree/promotion/rules/user.rb
spree_core-4.5.3 app/models/spree/promotion/rules/user.rb
spree_core-4.5.2 app/models/spree/promotion/rules/user.rb
spree_core-4.5.1 app/models/spree/promotion/rules/user.rb
spree_core-4.5.0 app/models/spree/promotion/rules/user.rb
spree_core-4.2.6 app/models/spree/promotion/rules/user.rb
spree_core-4.3.2 app/models/spree/promotion/rules/user.rb
spree_core-4.4.0 app/models/spree/promotion/rules/user.rb
spree_core-4.4.0.rc2 app/models/spree/promotion/rules/user.rb
spree_core-4.3.1 app/models/spree/promotion/rules/user.rb
spree_core-4.4.0.rc1 app/models/spree/promotion/rules/user.rb
spree_core-4.3.0 app/models/spree/promotion/rules/user.rb
spree_core-4.3.0.rc3 app/models/spree/promotion/rules/user.rb
spree_core-4.3.0.rc2 app/models/spree/promotion/rules/user.rb
spree_core-4.3.0.rc1 app/models/spree/promotion/rules/user.rb
spree_core-4.2.5 app/models/spree/promotion/rules/user.rb
spree_core-4.2.4 app/models/spree/promotion/rules/user.rb
spree_core-4.2.3.1 app/models/spree/promotion/rules/user.rb
spree_core-4.2.3 app/models/spree/promotion/rules/user.rb
spree_core-4.2.2 app/models/spree/promotion/rules/user.rb