Module: EVSSClaimBaseHelper

Included in:
EVSSClaimDetailSerializer, EVSSClaimListSerializer
Defined in:
app/serializers/evss_claim_base_helper.rb

Constant Summary collapse

PHASE_MAPPING =
{
  'claim received' => 1,
  'under review' => 2,
  'gathering of evidence' => 3,
  'review of evidence' => 4,
  'preparation for decision' => 5,
  'pending decision approval' => 6,
  'preparation for notification' => 7,
  'complete' => 8
}.freeze

Instance Method Summary collapse

Instance Method Details

#date_attr(date, format: '%m/%d/%Y') ⇒ Object



19
20
21
22
23
# File 'app/serializers/evss_claim_base_helper.rb', line 19

def date_attr(date, format: '%m/%d/%Y')
  return unless date

  Date.strptime(date, format)
end

#phase_from_keys(phase) ⇒ Object



15
16
17
# File 'app/serializers/evss_claim_base_helper.rb', line 15

def phase_from_keys(phase)
  PHASE_MAPPING[phase&.downcase]
end

#yes_no_attr(value, *names) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'app/serializers/evss_claim_base_helper.rb', line 25

def yes_no_attr(value, *names)
  return unless value

  case value.downcase
  when 'yes' then true
  when 'no' then false
  else
    Rails.logger.error "Expected key EVSS '#{names.join('/')}' to be Yes/No. Got '#{value}'."
    nil
  end
end