Sha256: 046500de2e8538d3722a627516ea3203f93499f86c8b715e3e97d86182641c1b

Contents?: true

Size: 689 Bytes

Versions: 13

Compression:

Stored size: 689 Bytes

Contents

module Spree
  class Promotion
    module Rules
      class User < PromotionRule
        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 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)
          self.user_ids = s.to_s.split(',').map(&:strip)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
spree_core-2.2.14 app/models/spree/promotion/rules/user.rb
spree_core-2.2.13 app/models/spree/promotion/rules/user.rb
spree_core-2.2.12 app/models/spree/promotion/rules/user.rb
spree_core-2.2.11 app/models/spree/promotion/rules/user.rb
spree_core-2.2.10 app/models/spree/promotion/rules/user.rb
spree_core-2.2.9 app/models/spree/promotion/rules/user.rb
spree_core-2.2.8 app/models/spree/promotion/rules/user.rb
spree_core-2.2.7 app/models/spree/promotion/rules/user.rb
spree_core-2.2.6 app/models/spree/promotion/rules/user.rb
spree_core-2.2.5 app/models/spree/promotion/rules/user.rb
spree_core-2.2.4 app/models/spree/promotion/rules/user.rb
spree_core-2.2.3 app/models/spree/promotion/rules/user.rb
spree_core-2.2.2 app/models/spree/promotion/rules/user.rb