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

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

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.

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

#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.

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