Class: Renalware::HD::Scheduling::Diary
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Renalware::HD::Scheduling::Diary
- Includes:
- Accountable
- Defined in:
- app/models/renalware/hd/scheduling/diary.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#slot_for(diurnal_period_code_id, station_id, day_of_week, valid_from: nil) ⇒ Object
Searchs the object graph rather than a SQL search.
Methods included from Accountable
#first_or_create_by!, #save_by, #save_by!, #update_by
Class Method Details
.policy_class ⇒ Object
31 32 33 |
# File 'app/models/renalware/hd/scheduling/diary.rb', line 31 def self.policy_class DiaryPolicy end |
Instance Method Details
#slot_for(diurnal_period_code_id, station_id, day_of_week, valid_from: nil) ⇒ Object
Searchs the object graph rather than a SQL search
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/renalware/hd/scheduling/diary.rb', line 36 def slot_for(diurnal_period_code_id, station_id, day_of_week, valid_from: nil) slots.find do |slot| found = slot.diurnal_period_code_id == diurnal_period_code_id && slot.station_id == station_id && slot.day_of_week == day_of_week # This applies to master diaries only really, where we only # show recurring slots if they were created before the timeframe # of the current week being viewed. if found && valid_from found = (slot.created_at <= valid_from.end_of_week) end found end end |