Sha256: 537144f3198409444d6b0faa1d31aad42e9cfe5d504e0028f8541343697a86da

Contents?: true

Size: 539 Bytes

Versions: 116

Compression:

Stored size: 539 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: ->(obj) { obj.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

116 entries across 116 versions & 1 rubygems

Version Path
renalware-core-2.0.127 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.126 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.125 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.124 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.123 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.121 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.120 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.119 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.118 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.117 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.116 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.115 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.113 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.112 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.111 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.110 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.109 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.108 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.106 app/documents/renalware/dated_confirmation.rb
renalware-core-2.0.105 app/documents/renalware/dated_confirmation.rb