Class: SpreeCmCommissioner::Promotion::Rules::Guest
- Inherits:
-
Spree::PromotionRule
- Object
- Spree::PromotionRule
- SpreeCmCommissioner::Promotion::Rules::Guest
show all
- Defined in:
- app/models/spree_cm_commissioner/promotion/rules/guest.rb
Constant Summary
collapse
- MATCH_POLICIES =
%w[any all none].freeze
Instance Method Summary
collapse
Instance Method Details
#actionable?(line_item) ⇒ Boolean
14
15
16
|
# File 'app/models/spree_cm_commissioner/promotion/rules/guest.rb', line 14
def actionable?(line_item)
match_policy_condition?(line_item)
end
|
#applicable?(promotable) ⇒ Boolean
9
10
11
|
# File 'app/models/spree_cm_commissioner/promotion/rules/guest.rb', line 9
def applicable?(promotable)
promotable.is_a?(Spree::Order)
end
|
#guest_eligible?(_guest, _line_item) ⇒ Boolean
31
32
33
|
# File 'app/models/spree_cm_commissioner/promotion/rules/guest.rb', line 31
def guest_eligible?(_guest, _line_item)
raise 'guest_eligible? should be implemented in a sub-class of SpreeCmCommissioner::Promotion::Rules::Guests'
end
|
#match_policy_condition?(line_item) ⇒ Boolean
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/models/spree_cm_commissioner/promotion/rules/guest.rb', line 18
def match_policy_condition?(line_item)
case preferred_match_policy
when 'all'
line_item.guests.all? { |guest| guest_eligible?(guest, line_item) }
when 'any'
line_item.guests.any? { |guest| guest_eligible?(guest, line_item) }
when 'none'
line_item.guests.none? { |guest| guest_eligible?(guest, line_item) }
else
false
end
end
|