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


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

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

Instance Attribute Details

#recurring_todoObject (readonly)

Returns the value of attribute recurring_todo


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

def recurring_todo
  @recurring_todo
end

Instance Method Details

#attributes_to_filterObject


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

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


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

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

#get_recurrence_selectorObject


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

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

#map_attributes(mapping) ⇒ Object


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

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


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

def selector_key
  :monthly_selector
end

#valid_selector?(selector) ⇒ Boolean


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

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