Class: Renalware::HD::DiarySlot

Inherits:
ApplicationRecord show all
Includes:
Accountable
Defined in:
app/models/renalware/hd/diary_slot.rb

Overview

TODO: Document

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Accountable

#first_or_create_by!, #save_by, #save_by!, #update_by

Instance Attribute Details

#change_typeObject

Virtual attribute used on a form to determine what action as preformed on the slot



29
30
31
# File 'app/models/renalware/hd/diary_slot.rb', line 29

def change_type
  @change_type
end

Class Method Details

.policy_classObject



57
58
59
# File 'app/models/renalware/hd/diary_slot.rb', line 57

def self.policy_class
  DiaryPolicy
end

Instance Method Details

#cell_idObject



78
79
80
# File 'app/models/renalware/hd/diary_slot.rb', line 78

def cell_id
  "#{diurnal_period_code&.id}-#{station&.id}-#{day_of_week}"
end

#day_of_week_nameObject



74
75
76
# File 'app/models/renalware/hd/diary_slot.rb', line 74

def day_of_week_name
  Time::DAYS_INTO_WEEK.keys[day_of_week - 1].capitalize
end

#descriptionObject



65
66
67
68
69
70
71
72
# File 'app/models/renalware/hd/diary_slot.rb', line 65

def description
  period = diurnal_period_code.code.upcase # e.g. AM
  if diary.master
    "Recurring every #{day_of_week_name} #{period}"
  else
    "This week only on #{day_of_week_name} #{period}"
  end
end

#on_master_diary?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'app/models/renalware/hd/diary_slot.rb', line 61

def on_master_diary?
  diary&.master?
end