Sha256: 0f85b77fcff32a682be97d558ac4a501f790887188158862f6a19cbc4ef0cc42

Contents?: true

Size: 445 Bytes

Versions: 55

Compression:

Stored size: 445 Bytes

Contents

# frozen_string_literal: true

module Renalware
  class DatedInteger < NestedAttribute
    attribute :result, Integer
    attribute :recorded_on, Date

    validates :recorded_on, timeliness: { type: :date, allow_blank: true }
    validates :recorded_on, presence: { if: ->{ result.present? } }

    def to_s
      datestamp = recorded_on.present? ? "(#{I18n.l(recorded_on)})" : nil
      [result, datestamp].compact.join(" ")
    end
  end
end

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
renalware-core-2.0.33 app/documents/renalware/dated_integer.rb
renalware-core-2.0.32 app/documents/renalware/dated_integer.rb
renalware-core-2.0.31 app/documents/renalware/dated_integer.rb
renalware-core-2.0.30 app/documents/renalware/dated_integer.rb
renalware-core-2.0.28 app/documents/renalware/dated_integer.rb
renalware-core-2.0.27 app/documents/renalware/dated_integer.rb
renalware-core-2.0.26 app/documents/renalware/dated_integer.rb
renalware-core-2.0.25 app/documents/renalware/dated_integer.rb
renalware-core-2.0.24 app/documents/renalware/dated_integer.rb
renalware-core-2.0.23 app/documents/renalware/dated_integer.rb
renalware-core-2.0.22 app/documents/renalware/dated_integer.rb
renalware-core-2.0.21 app/documents/renalware/dated_integer.rb
renalware-core-2.0.20 app/documents/renalware/dated_integer.rb
renalware-core-2.0.18 app/documents/renalware/dated_integer.rb
renalware-core-2.0.17 app/documents/renalware/dated_integer.rb