Sha256: 77384650d02819416573e627f1a33aa9c240167f525a70b626080dc30f7a7b62

Contents?: true

Size: 828 Bytes

Versions: 1

Compression:

Stored size: 828 Bytes

Contents

# frozen_string_literal: true

require "attr_extras"

module Renalware
  # A base class for Summary presenters in other name-spaces. SummaryParts can be composed into
  # reporting dashboards or summary pages. The Clinical Summary for instance comprises an array
  # of various SummaryParts
  class SummaryPart
    DATE_FORMAT = "%Y%m%d%H%M%S%L".freeze
    rattr_initialize :patient
    attr_implement :to_partial_path

    # If the subclass defines a cache_key Rails will cache the partial
    def cache_key
      nil
    end

    def render?
      true
    end

    protected

    def date_formatted_for_cache(date)
      date&.strftime(DATE_FORMAT)
    end

    def title_friendly_collection_count(actual:, total:)
      if total > actual
        "#{actual} of #{total}"
      else
        actual
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc13 app/presenters/renalware/summary_part.rb