Sha256: 15a38dd8f03bc9f71bd0cedc5615ce01c96f3bcb34145a53971df0cbd97c9f20

Contents?: true

Size: 957 Bytes

Versions: 97

Compression:

Stored size: 957 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/hd"

module Renalware
  module HD
    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: "Renalware::HD::WeeklyDiary"
      # While out DB constraints could check for the string "Renalware::HD::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

Version data entries

97 entries across 97 versions & 1 rubygems

Version Path
renalware-core-2.0.113 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.112 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.111 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.110 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.109 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.108 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.106 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.105 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.104 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.103 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.102 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.101 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.100 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.99 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.98 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.97 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.96 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.95 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.94 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.93 app/models/renalware/hd/master_diary.rb