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, #to_partial_path

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Methods included from Spree::Preferences::Preferable

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

Instance Method Details

#applicable?(promotable) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'app/models/spree/promotion/rules/user.rb', line 10

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

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

Returns:

  • (Boolean)


14
15
16
# File 'app/models/spree/promotion/rules/user.rb', line 14

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

#user_ids_stringObject



18
19
20
# File 'app/models/spree/promotion/rules/user.rb', line 18

def user_ids_string
  user_ids.join(',')
end

#user_ids_string=(s) ⇒ Object



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

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