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

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

Instance Method Summary collapse

Methods inherited from Spree::PromotionRule

#actionable?, #eligibility_errors, for

Methods inherited from Base

belongs_to_required_by_default, page, spree_base_scopes

Methods included from Spree::Preferences::Preferable

#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Instance Method Details

#applicable?(promotable) ⇒ Boolean


12
13
14
# File 'app/models/spree/promotion/rules/user.rb', line 12

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

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


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

def eligible?(order, _options = {})
  users.include?(order.user)
end

#user_ids_stringObject


20
21
22
# File 'app/models/spree/promotion/rules/user.rb', line 20

def user_ids_string
  user_ids.join(',')
end

#user_ids_string=(s) ⇒ Object


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

def user_ids_string=(s)
  self.user_ids = s.to_s.split(',').map(&:strip)
end