Sha256: def994be8d20f5433b66ef2452c783b43d600f0324275fc7feec917cfcc7b430
Contents?: true
Size: 1.01 KB
Versions: 52
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require_dependency "renalware/hd" module Renalware module HD module Scheduling class MasterDiary < Diary # Overwrite the existing master attribute to ensure it defaults to true attribute :master, :boolean, default: true validates :hospital_unit_id, uniqueness: true has_many :weekly_diaries, class_name: "WeeklyDiary" # While our DB constraints could check for the string # "Renalware::HD::Scheduling::MasterDiary" in the type column, this feels a bit fragile, so # instead a MasterDiary must have a corresponding # master = TRUE column validates :master, inclusion: { in: [true], allow_nil: false } class MasterSlotDecorator < SimpleDelegator def master? true end end def decorate_slot(slot) MasterSlotDecorator.new(slot) end def slot_for(*args) (slot = super) && decorate_slot(slot) end end end end end
Version data entries
52 entries across 52 versions & 1 rubygems