Class: SolidusFriendlyPromotions::Conditions::OptionValue
Instance Method Summary
collapse
#applicable?, #eligible?, included, #level
#applicable?, #eligibility_errors, #eligible?, #level, #preload_relations, #to_partial_path, #updateable?
Instance Method Details
#line_item_eligible?(line_item) ⇒ Boolean
14
15
16
|
# File 'app/models/solidus_friendly_promotions/conditions/option_value.rb', line 14
def line_item_eligible?(line_item)
LineItemOptionValue.new(preferred_eligible_values: preferred_eligible_values).eligible?(line_item)
end
|
#order_eligible?(order) ⇒ Boolean
10
11
12
|
# File 'app/models/solidus_friendly_promotions/conditions/option_value.rb', line 10
def order_eligible?(order)
order.line_items.any? { |item| line_item_eligible?(item) }
end
|
#preferred_eligible_values ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'app/models/solidus_friendly_promotions/conditions/option_value.rb', line 18
def preferred_eligible_values
values = preferences[:eligible_values] || {}
values.keys.map(&:to_i).zip(
values.values.map do |value|
(value.is_a?(Array) ? value : value.split(",")).map(&:to_i)
end
).to_h
end
|