Class: Spree::Promotion::Rules::AffiliatedPromotionRule
- Inherits:
-
Spree::PromotionRule
- Object
- Spree::PromotionRule
- Spree::Promotion::Rules::AffiliatedPromotionRule
- Defined in:
- app/models/spree/promotion/rules/affiliated_promotion_rule.rb
Instance Method Summary collapse
- #affiliate_ids_string ⇒ Object
- #affiliate_ids_string=(s) ⇒ Object
- #affiliate_list ⇒ Object
- #affiliate_list=(a) ⇒ Object
- #applicable?(promotable) ⇒ Boolean
- #eligible?(order, options = {}) ⇒ Boolean
Instance Method Details
#affiliate_ids_string ⇒ Object
19 20 21 |
# File 'app/models/spree/promotion/rules/affiliated_promotion_rule.rb', line 19 def affiliate_ids_string affiliate_ids.join(',') end |
#affiliate_ids_string=(s) ⇒ Object
23 24 25 |
# File 'app/models/spree/promotion/rules/affiliated_promotion_rule.rb', line 23 def affiliate_ids_string=(s) self.affiliate_ids = s.to_s.split(',').map(&:strip) end |
#affiliate_list ⇒ Object
27 28 29 |
# File 'app/models/spree/promotion/rules/affiliated_promotion_rule.rb', line 27 def affiliate_list affiliate_ids end |
#affiliate_list=(a) ⇒ Object
31 32 33 |
# File 'app/models/spree/promotion/rules/affiliated_promotion_rule.rb', line 31 def affiliate_list=(a) self.affiliate_ids = a end |
#applicable?(promotable) ⇒ Boolean
15 16 17 |
# File 'app/models/spree/promotion/rules/affiliated_promotion_rule.rb', line 15 def applicable?(promotable) promotable.is_a?(Spree::Order) end |
#eligible?(order, options = {}) ⇒ Boolean
10 11 12 13 |
# File 'app/models/spree/promotion/rules/affiliated_promotion_rule.rb', line 10 def eligible?(order, = {}) return true if order.user and order.user.affiliate? and affiliates.collect(&:id).include?(order.user.affiliate.id) false end |