Class: SpreeCmCommissioner::Promotion::Rules::FixedDate

Inherits:
Date
  • Object
show all
Defined in:
app/models/spree_cm_commissioner/promotion/rules/fixed_date.rb

Constant Summary

Constants inherited from Date

Date::MATCH_POLICIES

Instance Method Summary collapse

Methods inherited from Date

#actionable?, #applicable?, #eligible?, #line_item_eligible?

Instance Method Details

#date_eligible?(date) ⇒ Boolean

override

Returns:

  • (Boolean)


11
12
13
# File 'app/models/spree_cm_commissioner/promotion/rules/fixed_date.rb', line 11

def date_eligible?(date)
  date.between?(start_rule_date, end_rule_date)
end

#end_rule_dateObject



19
20
21
22
23
# File 'app/models/spree_cm_commissioner/promotion/rules/fixed_date.rb', line 19

def end_rule_date
  return nil if start_rule_date.nil? || preferred_length.nil?

  start_rule_date + preferred_length.days - 1
end

#start_rule_dateObject



15
16
17
# File 'app/models/spree_cm_commissioner/promotion/rules/fixed_date.rb', line 15

def start_rule_date
  preferred_start_date&.to_date
end