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.44 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.43 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.42 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.41 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.40 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.39 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.38 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.37 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.36 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.35 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.34 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.33 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.32 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.31 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.30 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.28 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.27 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.26 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.25 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.24 app/documents/renalware/dated_confirmation.rb