Class: Spree::Promotion::Rules::User

Inherits:
Spree::PromotionRule show all
Defined in:
app/models/spree/promotion/rules/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Spree::PromotionRule

#actionable?, #eligibility_errors, for, #human_description, #human_name, #key

Instance Attribute Details

#user_ids_to_addObject

Attributes



16
17
18
# File 'app/models/spree/promotion/rules/user.rb', line 16

def user_ids_to_add
  @user_ids_to_add
end

Instance Method Details

#applicable?(promotable) ⇒ Boolean

Returns:



23
24
25
# File 'app/models/spree/promotion/rules/user.rb', line 23

def applicable?(promotable)
  promotable.is_a?(Spree::Order)
end

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

Returns:



27
28
29
# File 'app/models/spree/promotion/rules/user.rb', line 27

def eligible?(order, _options = {})
  user_ids.include?(order.user_id)
end

#user_ids_stringObject



31
32
33
34
35
36
37
# File 'app/models/spree/promotion/rules/user.rb', line 31

def user_ids_string
  ActiveSupport::Deprecation.warn(
    'Spree::Promotion::Rules::User#user_ids_string is deprecated and will be removed in Spree 6.0. ' \
    'Please use `user_ids` instead.'
  )
  user_ids.join(',')
end

#user_ids_string=(s) ⇒ Object



39
40
41
42
43
44
45
# File 'app/models/spree/promotion/rules/user.rb', line 39

def user_ids_string=(s)
  ActiveSupport::Deprecation.warn(
    'Spree::Promotion::Rules::User#user_ids_string= is deprecated and will be removed in Spree 6.0. ' \
    'Please use `user_ids=` instead.'
  )
  self.user_ids = s
end