Class: Renalware::Pathology::ObservationSetPresenter

Inherits:
DumbDelegator
  • Object
show all
Defined in:
app/presenters/renalware/pathology/observation_set_presenter.rb

Defined Under Namespace

Classes: Observation

Instance Method Summary collapse

Methods inherited from DumbDelegator

#inspect, #public_send, #send, #try, #try!

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, **_args, &_block) ⇒ Object



13
14
15
16
17
18
# File 'app/presenters/renalware/pathology/observation_set_presenter.rb', line 13

def method_missing(method_name, **_args, &_block)
  return if __getobj__.nil?

  vals = __getobj__.values
  vals.public_send(method_name)
end

Instance Method Details

#each_display_groupObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/presenters/renalware/pathology/observation_set_presenter.rb', line 24

def each_display_group
  return unless block_given?

  ObservationDescription
    .in_display_order
    .to_a
    .group_by(&:display_group)
    .each do |group_number, array_of_obs_desc|
    group = array_of_obs_desc.map do |obs_desc|
      observation_hash = send(obs_desc.code.to_sym) || {}
      observed_at = observation_hash["observed_at"]
      Observation.new(
        code: obs_desc.code,
        result: observation_hash["result"],
        observed_at: observed_at && ::Time.zone.parse(observed_at),
        description: obs_desc
      )
    end

    yield group, group_number
  end
end

#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/presenters/renalware/pathology/observation_set_presenter.rb', line 20

def respond_to_missing?(method_name, _include_private = false)
  (values.present? && values.respond_to?(method_name)) || super
end