Class: Spree::VariantPropertyRule

Inherits:
Base
  • Object
show all
Defined in:
app/models/spree/variant_property_rule.rb

Instance Method Summary (collapse)

Methods inherited from Base

display_includes, #initialize_preference_defaults, page, preference

Methods included from Preferences::Preferable

#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Instance Method Details

- (Boolean) applies_to_variant?(variant)

Checks whether the rule applies to the variant by checking the rule's conditions against the variant's option values.

Parameters:

Returns:

  • (Boolean)


38
39
40
# File 'app/models/spree/variant_property_rule.rb', line 38

def applies_to_variant?(variant)
  (option_value_ids & variant.option_value_ids).present?
end

- (Boolean) matches_option_value_ids?(option_value_ids)

Checks whether the provided ids are the same as the rule's condition's option value ids.

Parameters:

  • option_value_ids (Array<Integer>)

    list of option value ids

Returns:

  • (Boolean)


28
29
30
# File 'app/models/spree/variant_property_rule.rb', line 28

def matches_option_value_ids?(option_value_ids)
  self.option_value_ids.sort == option_value_ids.sort
end