Class: Spree::VariantPropertyRule
- Defined in:
- app/models/spree/variant_property_rule.rb
Instance Method Summary collapse
-
#applies_to_variant?(variant) ⇒ Boolean
Checks whether the rule applies to the variant by checking the rule’s conditions against the variant’s option values.
-
#matches_option_value_ids?(option_value_ids) ⇒ Boolean
Checks whether the provided ids are the same as the rule’s condition’s option value ids.
Methods inherited from Base
Methods included from Core::Permalinks
#generate_permalink, #save_permalink
Instance Method Details
#applies_to_variant?(variant) ⇒ Boolean
Checks whether the rule applies to the variant by checking the rule’s conditions against the variant’s option values.
40 41 42 43 44 45 46 |
# File 'app/models/spree/variant_property_rule.rb', line 40 def applies_to_variant?(variant) if apply_to_all matches_option_value_ids?(variant.option_value_ids) else (option_value_ids & variant.option_value_ids).present? end end |
#matches_option_value_ids?(option_value_ids) ⇒ Boolean
Checks whether the provided ids are the same as the rule’s condition’s option value ids.
30 31 32 |
# File 'app/models/spree/variant_property_rule.rb', line 30 def matches_option_value_ids?(option_value_ids) self.option_value_ids.sort == option_value_ids.sort end |