Sha256: c3a8d3aaea78ae521ba5d3808064ac8e3bf6365f4f3747c35532716629cf620b

Contents?: true

Size: 1.16 KB

Versions: 16

Compression:

Stored size: 1.16 KB

Contents

require_dependency "renalware/pathology"

module Renalware
  module Pathology
    class CurrentObservationResults::Presenter
      attr_reader :view_model

      def present(results)
        @view_model = [build_header] + build_body(results)
      end

      private

      def build_header
        %w(description result date)
      end

      def build_body(results)
        results.map do |result|
          [build_description(result), ObservationPresenter.new(result), format_date(result)]
        end
      end

      def build_description(result)
        description = ObservationDescription.new(
          code: result.description_code, name: result.description_name)
        ResultPresenter.new(description)
      end

      def format_date(result)
        date = I18n.l(result.observed_at.try(:to_date))
        DatePresenter.new(date)
      end

      class DatePresenter < SimpleDelegator
        def content
          to_s
        end
      end

      class ResultPresenter < SimpleDelegator
        def content
          name
        end
      end

      class ObservationPresenter < SimpleDelegator
        def content
          to_s
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc8 app/presenters/renalware/pathology/current_observation_results.dead/presenter.rb.dead
renalware-core-2.0.0.pre.rc7 app/presenters/renalware/pathology/current_observation_results.dead/presenter.rb.dead
renalware-core-2.0.0.pre.rc6 app/presenters/renalware/pathology/current_observation_results.dead/presenter.rb.dead
renalware-core-2.0.0.pre.rc5 app/presenters/renalware/pathology/current_observation_results.dead/presenter.rb.dead
renalware-core-2.0.0.pre.rc4 app/presenters/renalware/pathology/current_observation_results.dead/presenter.rb.dead
renalware-core-2.0.0.pre.rc3 app/presenters/renalware/pathology/current_observation_results.dead/presenter.rb.dead
renalware-core-2.0.0.pre.rc1 app/presenters/renalware/pathology/current_observation_results/presenter.rb
renalware-core-2.0.0.pre.beta12 app/presenters/renalware/pathology/current_observation_results/presenter.rb
renalware-core-2.0.0.pre.beta11 app/presenters/renalware/pathology/current_observation_results/presenter.rb
renalware-core-2.0.0.pre.beta10 app/presenters/renalware/pathology/current_observation_results/presenter.rb
renalware-core-2.0.0.pre.beta9 app/presenters/renalware/pathology/current_observation_results/presenter.rb
renalware-core-2.0.0.pre.beta8 app/presenters/renalware/pathology/current_observation_results/presenter.rb
renalware-core-2.0.0.pre.beta7 app/presenters/renalware/pathology/current_observation_results/presenter.rb
renalware-core-2.0.0.pre.beta6 app/presenters/renalware/pathology/current_observation_results/presenter.rb
renalware-core-2.0.0.pre.beta5 app/presenters/renalware/pathology/current_observation_results/presenter.rb
renalware-core-2.0.0.pre.beta4 app/presenters/renalware/pathology/current_observation_results/presenter.rb