Class: RecurringTodos::MonthlyRecurringTodosBuilder

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

Instance Attribute Summary collapse

Attributes inherited from AbstractRecurringTodosBuilder

#mapped_attributes, #pattern

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) ⇒ MonthlyRecurringTodosBuilder

Returns a new instance of MonthlyRecurringTodosBuilder.



5
6
7
# File 'app/models/recurring_todos/monthly_recurring_todos_builder.rb', line 5

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

Instance Attribute Details

#recurring_todoObject (readonly)

Returns the value of attribute recurring_todo.



3
4
5
# File 'app/models/recurring_todos/monthly_recurring_todos_builder.rb', line 3

def recurring_todo
  @recurring_todo
end

Instance Method Details

#attributes_to_filterObject



9
10
11
12
13
14
# File 'app/models/recurring_todos/monthly_recurring_todos_builder.rb', line 9

def attributes_to_filter
  %w{
    monthly_selector       monthly_every_x_day   monthly_every_x_month
    monthly_every_x_month2 monthly_every_xth_day monthly_day_of_week
  }
end

#get_every_other2Object



31
32
33
# File 'app/models/recurring_todos/monthly_recurring_todos_builder.rb', line 31

def get_every_other2
  get_recurrence_selector == 0 ? 'monthly_every_x_month' : 'monthly_every_x_month2'
end

#get_recurrence_selectorObject



27
28
29
# File 'app/models/recurring_todos/monthly_recurring_todos_builder.rb', line 27

def get_recurrence_selector
  @selector == 'monthly_every_x_day' ? 0 : 1
end

#map_attributes(mapping) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'app/models/recurring_todos/monthly_recurring_todos_builder.rb', line 16

def map_attributes(mapping)
  mapping = map(mapping, :every_other1, 'monthly_every_x_day')
  mapping = map(mapping, :every_other3, 'monthly_every_xth_day')
  mapping = map(mapping, :every_count,  'monthly_day_of_week')

  mapping.set(:recurrence_selector, get_recurrence_selector)

  mapping.set(:every_other2, mapping.get(get_every_other2))
  mapping.except('monthly_every_x_month').except('monthly_every_x_month2')
end

#selector_keyObject



35
36
37
# File 'app/models/recurring_todos/monthly_recurring_todos_builder.rb', line 35

def selector_key
  :monthly_selector
end

#valid_selector?(selector) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'app/models/recurring_todos/monthly_recurring_todos_builder.rb', line 39

def valid_selector?(selector)
  %w{monthly_every_x_day monthly_every_xth_day}.include?(selector)
end