Class: RecurringTodos::DailyRecurringTodosBuilder

Inherits:
AbstractRecurringTodosBuilder show all
Defined in:
app/models/recurring_todos/daily_recurring_todos_builder.rb

Instance Attribute Summary collapse

Attributes inherited from AbstractRecurringTodosBuilder

#mapped_attributes

Instance Method Summary collapse

Methods inherited from AbstractRecurringTodosBuilder

#attributes, #build, #errors, #filter_attributes, #filter_generic_attributes, #get_selector, #map, #save, #save_collection, #save_context, #save_project, #save_recurring_todo, #save_tags, #saved_recurring_todo, #tag_list_or_empty_string, #update

Constructor Details

#initialize(user, attributes) ⇒ DailyRecurringTodosBuilder

Returns a new instance of DailyRecurringTodosBuilder


6
7
8
# File 'app/models/recurring_todos/daily_recurring_todos_builder.rb', line 6

def initialize(user, attributes)
  super(user, attributes, DailyRepeatPattern)
end

Instance Attribute Details

#patternObject (readonly)

Returns the value of attribute pattern


4
5
6
# File 'app/models/recurring_todos/daily_recurring_todos_builder.rb', line 4

def pattern
  @pattern
end

#recurring_todoObject (readonly)

Returns the value of attribute recurring_todo


4
5
6
# File 'app/models/recurring_todos/daily_recurring_todos_builder.rb', line 4

def recurring_todo
  @recurring_todo
end

Instance Method Details

#attributes_to_filterObject


10
11
12
# File 'app/models/recurring_todos/daily_recurring_todos_builder.rb', line 10

def attributes_to_filter
  %w{daily_selector daily_every_x_days}
end

#map_attributes(mapping) ⇒ Object


14
15
16
17
18
# File 'app/models/recurring_todos/daily_recurring_todos_builder.rb', line 14

def map_attributes(mapping)
  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)
end

#only_work_days?(daily_selector) ⇒ Boolean

Returns:

  • (Boolean)

20
21
22
23
# File 'app/models/recurring_todos/daily_recurring_todos_builder.rb', line 20

def only_work_days?(daily_selector)
  { 'daily_every_x_day' => false,
    'daily_every_work_day' => true}[daily_selector]
end

#selector_keyObject


25
26
27
# File 'app/models/recurring_todos/daily_recurring_todos_builder.rb', line 25

def selector_key
  :daily_selector
end

#valid_selector?(selector) ⇒ Boolean

Returns:

  • (Boolean)

29
30
31
# File 'app/models/recurring_todos/daily_recurring_todos_builder.rb', line 29

def valid_selector?(selector)
  %w{daily_every_x_day daily_every_work_day}.include?(selector)
end