Sha256: 9c8a208107d11c372afaa8a0ed83b69f6966b5bd1db26828f177204c39cb9add

Contents?: true

Size: 535 Bytes

Versions: 26

Compression:

Stored size: 535 Bytes

Contents

# frozen_string_literal: true

require "document/enum"

module Renalware
  class DatedConfirmation < NestedAttribute
    attribute :status, Document::Enum, enums: %i(yes no unknown)
    attribute :confirmed_on, Date

    validates :confirmed_on, timeliness: { type: :date, allow_blank: true }
    validates :confirmed_on, presence: true, if: ->(o) { o.status.try(:yes?) }

    def to_s
      datestamp = confirmed_on.present? ? "(#{I18n.l(confirmed_on)})" : nil
      [status.try(:text), datestamp].compact.join(" ")
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
renalware-core-2.0.23 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.22 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.21 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.20 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.18 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.17 app/documents/renalware/dated_confirmation.rb