Class: Spree::Promotion::Rules::UserLoggedIn Private

Inherits:
Spree::PromotionRule show all
Defined in:
app/models/spree/promotion/rules/user_logged_in.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 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 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.

Returns:

  • (Boolean)


5
6
7
# File 'app/models/spree/promotion/rules/user_logged_in.rb', line 5

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.

Returns:

  • (Boolean)


9
10
11
12
13
14
# File 'app/models/spree/promotion/rules/user_logged_in.rb', line 9

def eligible?(order, _options = {})
  unless order.user.present?
    eligibility_errors.add(:base, eligibility_error_message(:no_user_specified))
  end
  eligibility_errors.empty?
end