Sha256: 50483ca299fbe99365e680ac4213849af2b84f632df61fa01c8652f37ebc1cfe

Contents?: true

Size: 613 Bytes

Versions: 8

Compression:

Stored size: 613 Bytes

Contents

require "document/enum"

module Renalware
  class YearDatedConfirmation < NestedAttribute
    attribute :status, Document::Enum, enums: %i(yes no unknown)
    attribute :confirmed_on_year, Integer

    validates :confirmed_on_year, numericality: { allow_blank: true, only_integer: true }
    validates :confirmed_on_year, presence: true, if: ->(o) { o.status.try!(:yes?) }

    def self.valid_years
      (1900..Time.zone.today.year).to_a
    end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta11 app/documents/renalware/year_dated_confirmation.rb
renalware-core-2.0.0.pre.beta10 app/documents/renalware/year_dated_confirmation.rb
renalware-core-2.0.0.pre.beta9 app/documents/renalware/year_dated_confirmation.rb
renalware-core-2.0.0.pre.beta8 app/documents/renalware/year_dated_confirmation.rb
renalware-core-2.0.0.pre.beta7 app/documents/renalware/year_dated_confirmation.rb
renalware-core-2.0.0.pre.beta6 app/documents/renalware/year_dated_confirmation.rb
renalware-core-2.0.0.pre.beta5 app/documents/renalware/year_dated_confirmation.rb
renalware-core-2.0.0.pre.beta4 app/documents/renalware/year_dated_confirmation.rb