Class: SolidusFriendlyPromotions::Condition

Inherits:
Spree::Base
  • Object
show all
Includes:
Spree::Preferences::Persistable
Defined in:
app/models/solidus_friendly_promotions/condition.rb

Instance Method Summary collapse

Instance Method Details

#applicable?(_promotable) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


21
22
23
# File 'app/models/solidus_friendly_promotions/condition.rb', line 21

def applicable?(_promotable)
  raise NotImplementedError, "applicable? should be implemented in a sub-class of SolidusFriendlyPromotions::Rule"
end

#eligibility_errorsObject



33
34
35
# File 'app/models/solidus_friendly_promotions/condition.rb', line 33

def eligibility_errors
  @eligibility_errors ||= ActiveModel::Errors.new(self)
end

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

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


25
26
27
# File 'app/models/solidus_friendly_promotions/condition.rb', line 25

def eligible?(_promotable, _options = {})
  raise NotImplementedError, "eligible? should be implemented in a sub-class of SolidusFriendlyPromotions::Rule"
end

#levelObject

Raises:

  • (NotImplementedError)


29
30
31
# File 'app/models/solidus_friendly_promotions/condition.rb', line 29

def level
  raise NotImplementedError, "level should be implemented in a sub-class of SolidusFriendlyPromotions::Rule"
end

#preload_relationsObject



17
18
19
# File 'app/models/solidus_friendly_promotions/condition.rb', line 17

def preload_relations
  []
end

#to_partial_pathObject



37
38
39
# File 'app/models/solidus_friendly_promotions/condition.rb', line 37

def to_partial_path
  "solidus_friendly_promotions/admin/condition_fields/#{model_name.element}"
end

#updateable?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/models/solidus_friendly_promotions/condition.rb', line 41

def updateable?
  preferences.any?
end