Class: Spree::Promotion::Rules::FirstOrder Private
- Inherits:
-
Spree::PromotionRule
- Object
- ActiveRecord::Base
- Base
- Spree::PromotionRule
- Spree::Promotion::Rules::FirstOrder
- Defined in:
- app/models/spree/promotion/rules/first_order.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #email ⇒ Object readonly private
- #user ⇒ Object readonly private
Instance Method Summary collapse
Methods inherited from Spree::PromotionRule
#actionable?, #eligibility_errors, for
Methods inherited from Base
display_includes, #initialize_preference_defaults, page, preference
Methods included from Spree::Preferences::Preferable
#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Instance Attribute Details
#email ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'app/models/spree/promotion/rules/first_order.rb', line 5 def email @email end |
#user ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'app/models/spree/promotion/rules/first_order.rb', line 5 def user @user end |
Instance Method Details
#applicable?(promotable) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 |
# File 'app/models/spree/promotion/rules/first_order.rb', line 7 def applicable?(promotable) promotable.is_a?(Spree::Order) end |
#eligible?(order, options = {}) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/spree/promotion/rules/first_order.rb', line 11 def eligible?(order, = {}) @user = order.try(:user) || [:user] @email = order.email if user || email if !completed_orders.blank? && completed_orders.first != order eligibility_errors.add(:base, (:not_first_order)) end else eligibility_errors.add(:base, (:no_user_or_email_specified)) end eligibility_errors.empty? end |