Class: SolidusFriendlyPromotions::Conditions::UserRole

Inherits:
SolidusFriendlyPromotions::Condition show all
Includes:
OrderLevelCondition
Defined in:
app/models/solidus_friendly_promotions/conditions/user_role.rb

Constant Summary collapse

MATCH_POLICIES =
%w[any all].freeze

Instance Method Summary collapse

Methods included from OrderLevelCondition

#applicable?, #level

Methods inherited from SolidusFriendlyPromotions::Condition

#applicable?, #eligibility_errors, #level, #preload_relations, #to_partial_path, #updateable?

Instance Method Details

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

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
# File 'app/models/solidus_friendly_promotions/conditions/user_role.rb', line 13

def eligible?(order, _options = {})
  return false unless order.user

  if all_match_policy?
    match_all_roles?(order)
  else
    match_any_roles?(order)
  end
end