Sha256: 44e1bb0b2a4db6275e994c74b17949fc56b4c933ba9e6cf575f2a5e908c285de

Contents?: true

Size: 926 Bytes

Versions: 20

Compression:

Stored size: 926 Bytes

Contents

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

20 entries across 20 versions & 1 rubygems

Version Path
renalware-core-2.0.8 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.7 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.5 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.4 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.3 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.2 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.1 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.0 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.0.pre.rc13 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.0.pre.rc11 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.0.pre.rc10 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.0.pre.rc9 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.0.pre.rc8 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.0.pre.rc7 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.0.pre.rc6 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.0.pre.rc5 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.0.pre.rc4 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.0.pre.rc3 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.0.pre.rc1 app/models/renalware/hd/master_diary.rb
renalware-core-2.0.0.pre.beta12 app/models/renalware/hd/master_diary.rb