Class: SpreeCmCommissioner::Promotion::Rules::GuestOccupations

Inherits:
Guest
  • Object
show all
Defined in:
app/models/spree_cm_commissioner/promotion/rules/guest_occupations.rb

Constant Summary

Constants inherited from Guest

SpreeCmCommissioner::Promotion::Rules::Guest::MATCH_POLICIES

Instance Method Summary collapse

Methods inherited from Guest

#actionable?, #applicable?, #match_policy_condition?

Instance Method Details

#eligible?(order, _options = {}) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
# File 'app/models/spree_cm_commissioner/promotion/rules/guest_occupations.rb', line 17

def eligible?(order, _options = {})
  return true if eligible_guest_occupations.empty?

  order.line_items.any? do |line_item|
    match_policy_condition?(line_item)
  end
end

#eligible_guest_occupationsObject



12
13
14
# File 'app/models/spree_cm_commissioner/promotion/rules/guest_occupations.rb', line 12

def eligible_guest_occupations
  guest_occupations
end

#guest_eligible?(guest, line_item) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/models/spree_cm_commissioner/promotion/rules/guest_occupations.rb', line 26

def guest_eligible?(guest, line_item)
  eligible_guest_occupations.include?(guest.occupation) && line_item.product.kyc?
end

#guest_occupation_ids_stringObject



30
31
32
# File 'app/models/spree_cm_commissioner/promotion/rules/guest_occupations.rb', line 30

def guest_occupation_ids_string
  guest_occupation_ids.join(',')
end

#guest_occupation_ids_string=(value) ⇒ Object



34
35
36
# File 'app/models/spree_cm_commissioner/promotion/rules/guest_occupations.rb', line 34

def guest_occupation_ids_string=(value)
  self.guest_occupation_ids = value
end