class Promotion

Attributes

name[R]
promotion_code[R]
promotion_rules[RW]

Public Class Methods

new(name, promotion_code) click to toggle source
# File lib/wunder/promotion.rb, line 9
def initialize(name, promotion_code)
  @name = name
  @promotion_code = promotion_code
  @promotion_rules = PromotionalRulesCollection.new
end

Public Instance Methods

add_rule(promotion_rule) click to toggle source
# File lib/wunder/promotion.rb, line 15
def add_rule(promotion_rule)
  rule = promotion_rules.find_promotional_rule(promotion_rule)
  promotion_rules.push(promotion_rule) if rule.nil?
end
add_rules_in_bulk(promotion_rules) click to toggle source
# File lib/wunder/promotion.rb, line 25
def add_rules_in_bulk(promotion_rules)
  promotion_rules.each do |promotion_rule|
    add_rule(promotion_rule)
  end
end
remove_rule(promotion_rule) click to toggle source
# File lib/wunder/promotion.rb, line 20
def remove_rule(promotion_rule)
  rule = promotion_rules.find_promotional_rule(promotion_rule)
  promotion_rules.delete(rule) unless rule.nil?
end