2014-01-27 16:42:54 +01:00
|
|
|
module RecurringTodos
|
|
|
|
|
|
|
|
|
|
class DailyRecurringTodosBuilder < AbstractRecurringTodosBuilder
|
|
|
|
|
attr_reader :recurring_todo, :pattern
|
|
|
|
|
|
|
|
|
|
def initialize(user, attributes)
|
2015-02-10 16:25:27 +01:00
|
|
|
super(user, attributes, DailyRecurrencePattern)
|
2014-01-27 16:42:54 +01:00
|
|
|
end
|
|
|
|
|
|
2014-02-03 10:48:21 +01:00
|
|
|
def attributes_to_filter
|
|
|
|
|
%w{daily_selector daily_every_x_days}
|
2014-01-27 16:42:54 +01:00
|
|
|
end
|
|
|
|
|
|
2014-02-07 22:55:52 +01:00
|
|
|
def map_attributes(mapping)
|
2014-02-09 21:48:52 +01:00
|
|
|
mapping.set(:only_work_days, only_work_days?(@selector))
|
|
|
|
|
mapping.set(:every_other1, mapping.get(:daily_every_x_days))
|
|
|
|
|
mapping.except(:daily_every_x_days)
|
2014-02-07 22:55:52 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def only_work_days?(daily_selector)
|
2014-08-14 21:05:05 -05:00
|
|
|
{ 'daily_every_x_day' => false,
|
2014-02-09 21:48:52 +01:00
|
|
|
'daily_every_work_day' => true}[daily_selector]
|
2014-02-07 22:55:52 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def selector_key
|
2014-02-09 21:48:52 +01:00
|
|
|
:daily_selector
|
2014-02-07 22:55:52 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def valid_selector?(selector)
|
|
|
|
|
%w{daily_every_x_day daily_every_work_day}.include?(selector)
|
|
|
|
|
end
|
|
|
|
|
|
2014-01-27 16:42:54 +01:00
|
|
|
end
|
|
|
|
|
|
2014-08-14 21:05:05 -05:00
|
|
|
end
|