Class: SpreeCmCommissioner::Transit::ServiceCalendarForm

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/spree_cm_commissioner/transit/service_calendar_form.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ ServiceCalendarForm

Returns a new instance of ServiceCalendarForm.



17
18
19
20
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 17

def initialize(attrs = {})
  super
  @exception_rules ||= []
end

Instance Attribute Details

#end_dateObject

Returns the value of attribute end_date.



5
6
7
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 5

def end_date
  @end_date
end

#exception_rulesObject

Returns the value of attribute exception_rules.



5
6
7
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 5

def exception_rules
  @exception_rules
end

#fridayObject

Returns the value of attribute friday.



5
6
7
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 5

def friday
  @friday
end

#mondayObject

Returns the value of attribute monday.



5
6
7
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 5

def monday
  @monday
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 5

def name
  @name
end

#saturdayObject

Returns the value of attribute saturday.



5
6
7
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 5

def saturday
  @saturday
end

#start_dateObject

Returns the value of attribute start_date.



5
6
7
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 5

def start_date
  @start_date
end

#sundayObject

Returns the value of attribute sunday.



5
6
7
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 5

def sunday
  @sunday
end

#thursdayObject

Returns the value of attribute thursday.



5
6
7
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 5

def thursday
  @thursday
end

#tuesdayObject

Returns the value of attribute tuesday.



5
6
7
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 5

def tuesday
  @tuesday
end

#wednesdayObject

Returns the value of attribute wednesday.



5
6
7
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 5

def wednesday
  @wednesday
end

Instance Method Details

#weekdaysObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 22

def weekdays
  {
    'monday' => monday,
    'tuesday' => tuesday,
    'wednesday' => wednesday,
    'thursday' => thursday,
    'friday' => friday,
    'saturday' => saturday,
    'sunday' => sunday
  }
end

#weekdays=(hash) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 34

def weekdays=(hash)
  hash = hash.transform_keys(&:to_s)
  @monday = cast_bool(hash['monday'])
  @tuesday = cast_bool(hash['tuesday'])
  @wednesday = cast_bool(hash['wednesday'])
  @thursday = cast_bool(hash['thursday'])
  @friday = cast_bool(hash['friday'])
  @saturday = cast_bool(hash['saturday'])
  @sunday = cast_bool(hash['sunday'])
end