class PromotionalRule
Attributes
discount_type[R]
label[R]
on_item[R]
rule[R]
Public Class Methods
new(label, discount_type, on_item, rule, no_validate = false)
click to toggle source
# File lib/wunder/promotional_rule.rb, line 8 def initialize(label, discount_type, on_item, rule, no_validate = false) @label = label @discount_type = discount_type @on_item = on_item @rule = rule validate if no_validate == false end
Public Instance Methods
adjustable?(_total)
click to toggle source
# File lib/wunder/promotional_rule.rb, line 21 def adjustable?(_total) raise "Should be defined by the respective rule" end
calculate_discounted_price()
click to toggle source
# File lib/wunder/promotional_rule.rb, line 32 def calculate_discounted_price raise "Should be defined by the respective rule" end
calculate_total(arg)
click to toggle source
# File lib/wunder/promotional_rule.rb, line 40 def calculate_total(arg) if on_item == true rule.calculate_discounted_price(arg, discount_type) else rule.calculate_total_discounted_price(arg, discount_type) end end
calculate_total_discounted_price()
click to toggle source
# File lib/wunder/promotional_rule.rb, line 36 def calculate_total_discounted_price raise "Should be defined by the respective rule" end
eligible?()
click to toggle source
# File lib/wunder/promotional_rule.rb, line 17 def eligible? raise "Should be defined by the respective rule" end
validate()
click to toggle source
# File lib/wunder/promotional_rule.rb, line 25 def validate should_be_present("label", label) check_discount_type(discount_type) should_be_a_boolean("PromotionaRule::OnItem", on_item) should_be_present("PromotionalRule::Rule", rule) end