Class: SpreeCmCommissioner::Transit::ServiceCalendarForm
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::Transit::ServiceCalendarForm
- Includes:
- ActiveModel::Model
- Defined in:
- lib/spree_cm_commissioner/transit/service_calendar_form.rb
Instance Attribute Summary collapse
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#exception_rules ⇒ Object
Returns the value of attribute exception_rules.
-
#friday ⇒ Object
Returns the value of attribute friday.
-
#monday ⇒ Object
Returns the value of attribute monday.
-
#name ⇒ Object
Returns the value of attribute name.
-
#saturday ⇒ Object
Returns the value of attribute saturday.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
-
#sunday ⇒ Object
Returns the value of attribute sunday.
-
#thursday ⇒ Object
Returns the value of attribute thursday.
-
#tuesday ⇒ Object
Returns the value of attribute tuesday.
-
#wednesday ⇒ Object
Returns the value of attribute wednesday.
Class Method Summary collapse
-
.from_service_calendar(calendar) ⇒ Object
Create form from ServiceCalendar ActiveRecord object.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ ServiceCalendarForm
constructor
A new instance of ServiceCalendarForm.
- #weekdays ⇒ Object
- #weekdays=(hash) ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ ServiceCalendarForm
Returns a new instance of ServiceCalendarForm.
20 21 22 23 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 20 def initialize(attrs = {}) super @exception_rules ||= [] end |
Instance Attribute Details
#end_date ⇒ Object
Returns the value of attribute end_date.
8 9 10 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 8 def end_date @end_date end |
#exception_rules ⇒ Object
Returns the value of attribute exception_rules.
8 9 10 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 8 def exception_rules @exception_rules end |
#friday ⇒ Object
Returns the value of attribute friday.
8 9 10 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 8 def friday @friday end |
#monday ⇒ Object
Returns the value of attribute monday.
8 9 10 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 8 def monday @monday end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 8 def name @name end |
#saturday ⇒ Object
Returns the value of attribute saturday.
8 9 10 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 8 def saturday @saturday end |
#start_date ⇒ Object
Returns the value of attribute start_date.
8 9 10 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 8 def start_date @start_date end |
#sunday ⇒ Object
Returns the value of attribute sunday.
8 9 10 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 8 def sunday @sunday end |
#thursday ⇒ Object
Returns the value of attribute thursday.
8 9 10 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 8 def thursday @thursday end |
#tuesday ⇒ Object
Returns the value of attribute tuesday.
8 9 10 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 8 def tuesday @tuesday end |
#wednesday ⇒ Object
Returns the value of attribute wednesday.
8 9 10 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 8 def wednesday @wednesday end |
Class Method Details
.from_service_calendar(calendar) ⇒ Object
Create form from ServiceCalendar ActiveRecord object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 26 def self.from_service_calendar(calendar) return new if calendar.blank? new( name: calendar.name, start_date: calendar.start_date, end_date: calendar.end_date, monday: calendar.monday, tuesday: calendar.tuesday, wednesday: calendar.wednesday, thursday: calendar.thursday, friday: calendar.friday, saturday: calendar.saturday, sunday: calendar.sunday, exception_rules: calendar.exception_rules || [] ) end |
Instance Method Details
#weekdays ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 44 def weekdays { 'monday' => monday, 'tuesday' => tuesday, 'wednesday' => wednesday, 'thursday' => thursday, 'friday' => friday, 'saturday' => saturday, 'sunday' => sunday } end |
#weekdays=(hash) ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/spree_cm_commissioner/transit/service_calendar_form.rb', line 56 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 |