Class: Spree::Promotion::Rules::User
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#actionable?, #eligibility_errors, for, human_description, #human_description, human_name, #human_name, #key
Instance Attribute Details
#user_ids_to_add ⇒ Object
37
38
39
|
# File 'app/models/spree/promotion/rules/user.rb', line 37
def user_ids_to_add
@user_ids_to_add
end
|
Class Method Details
.additional_permitted_attributes ⇒ Object
Customers, not admin users — the rule keys off ‘Spree::Order#user_id`. The data layer keeps the `users` association (legacy column name); the API exposes the same set as `customer_ids`.
16
17
18
|
# File 'app/models/spree/promotion/rules/user.rb', line 16
def self.additional_permitted_attributes
[customer_ids: []]
end
|
.api_type ⇒ Object
Wire-format shorthand is ‘customer` (the model is still `User` pre-6.0 rename, see docs/plans/6.0-platform-auth.md).
22
23
24
|
# File 'app/models/spree/promotion/rules/user.rb', line 22
def self.api_type
'customer'
end
|
Instance Method Details
#applicable?(promotable) ⇒ Boolean
44
45
46
|
# File 'app/models/spree/promotion/rules/user.rb', line 44
def applicable?(promotable)
promotable.is_a?(Spree::Order)
end
|
#customer_ids ⇒ Object
26
27
28
|
# File 'app/models/spree/promotion/rules/user.rb', line 26
def customer_ids
user_ids
end
|
#customer_ids=(ids) ⇒ Object
30
31
32
|
# File 'app/models/spree/promotion/rules/user.rb', line 30
def customer_ids=(ids)
self.user_ids = ids
end
|
#eligible?(order, _options = {}) ⇒ Boolean
52
53
54
|
# File 'app/models/spree/promotion/rules/user.rb', line 52
def eligible?(order, _options = {})
eligible_user_ids.include?(order.user_id)
end
|
#eligible_user_ids ⇒ Object
48
49
50
|
# File 'app/models/spree/promotion/rules/user.rb', line 48
def eligible_user_ids
@eligible_user_ids ||= promotion_rule_users.pluck(:user_id)
end
|
#user_ids_string ⇒ Object
56
57
58
59
60
61
62
|
# File 'app/models/spree/promotion/rules/user.rb', line 56
def user_ids_string
ActiveSupport::Deprecation.warn(
'Spree::Promotion::Rules::User#user_ids_string is deprecated and will be removed in Spree 5.5. ' \
'Please use `user_ids` instead.'
)
user_ids.join(',')
end
|
#user_ids_string=(s) ⇒ Object
64
65
66
67
68
69
70
|
# File 'app/models/spree/promotion/rules/user.rb', line 64
def user_ids_string=(s)
ActiveSupport::Deprecation.warn(
'Spree::Promotion::Rules::User#user_ids_string= is deprecated and will be removed in Spree 5.5. ' \
'Please use `user_ids=` instead.'
)
self.user_ids = s
end
|