Class: SpreeCmCommissioner::Promotion::Rules::CustomDates

Inherits:
Date
  • Object
show all
Defined in:
app/models/spree_cm_commissioner/promotion/rules/custom_dates.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)


15
16
17
18
19
20
21
# File 'app/models/spree_cm_commissioner/promotion/rules/custom_dates.rb', line 15

def date_eligible?(date)
  return false if preferred_custom_dates.blank?

  preferred_custom_dates.any? do |custom_date|
    match?(custom_date, date)
  end
end

#sort_custom_datesObject



10
11
12
# File 'app/models/spree_cm_commissioner/promotion/rules/custom_dates.rb', line 10

def sort_custom_dates
  self.preferred_custom_dates = preferred_custom_dates.sort_by { |obj| JSON.parse(obj)['start_date'] }
end