Sha256: 11b358a273c72537ef793d86b61e5ac363b64cb003c391e52886eebc6e58551b

Contents?: true

Size: 797 Bytes

Versions: 1

Compression:

Stored size: 797 Bytes

Contents

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.rc11 app/presenters/renalware/summary_part.rb