Class: RecurringTodos::YearlyRecurringTodosBuilder

Inherits:
AbstractRecurringTodosBuilder show all
Defined in:
app/models/recurring_todos/yearly_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) ⇒ YearlyRecurringTodosBuilder


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

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

Instance Attribute Details

#recurring_todoObject (readonly)

Returns the value of attribute recurring_todo


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

def recurring_todo
  @recurring_todo
end

Instance Method Details

#attributes_to_filterObject


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

def attributes_to_filter
  %w{ yearly_selector     yearly_month_of_year  yearly_month_of_year2
      yearly_every_x_day  yearly_every_xth_day  yearly_day_of_week
  }
end

#get_every_other2Object


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

def get_every_other2
  { 0 => :yearly_month_of_year, 1 => :yearly_month_of_year2 }[get_recurrence_selector]
end

#get_recurrence_selectorObject


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

def get_recurrence_selector
  @selector=='yearly_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/yearly_recurring_todos_builder.rb', line 16

def map_attributes(mapping)
  mapping.set(:recurrence_selector, get_recurrence_selector)
  mapping.set(:every_other2,        mapping.get(get_every_other2))

  mapping = map(mapping, :every_other1, 'yearly_every_x_day')
  mapping = map(mapping, :every_other3, 'yearly_every_xth_day')
  mapping = map(mapping, :every_count,  'yearly_day_of_week')

  mapping.except(:yearly_month_of_year).except(:yearly_month_of_year2)
end

#selector_keyObject


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

def selector_key
  :yearly_selector
end

#valid_selector?(selector) ⇒ Boolean


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

def valid_selector?(selector)
  %w{yearly_every_x_day yearly_every_xth_day}.include?(selector.to_s)
end