Class: Spree::Promotion::Rules::UserRole
- Inherits:
-
Spree::PromotionRule
- Object
- ActiveRecord::Base
- Base
- Spree::PromotionRule
- Spree::Promotion::Rules::UserRole
- Defined in:
- app/models/spree/promotion/rules/user_role.rb
Constant Summary collapse
- MATCH_POLICIES =
%w(any all)
Instance Method Summary collapse
Methods inherited from Spree::PromotionRule
#actionable?, #eligibility_errors, #preload_relations, #to_partial_path
Methods inherited from Base
Methods included from Core::Permalinks
#generate_permalink, #save_permalink
Instance Method Details
#applicable?(promotable) ⇒ Boolean
12 13 14 |
# File 'app/models/spree/promotion/rules/user_role.rb', line 12 def applicable?(promotable) promotable.is_a?(Spree::Order) end |
#eligible?(order, _options = {}) ⇒ Boolean
16 17 18 19 20 21 22 23 |
# File 'app/models/spree/promotion/rules/user_role.rb', line 16 def eligible?(order, = {}) return false unless order.user if all_match_policy? match_all_roles?(order) else match_any_roles?(order) end end |