Class: EVSS::Letters::BeneficiaryResponse

Inherits:
Response show all
Defined in:
lib/evss/letters/beneficiary_response.rb

Overview

Model for beneficiary responses.

Constant Summary

Constants included from Common::Client::Concerns::ServiceStatus

Common::Client::Concerns::ServiceStatus::RESPONSE_STATUS

Instance Attribute Summary collapse

Attributes inherited from Common::Base

#errors_hash, #metadata

Instance Method Summary collapse

Methods inherited from Response

#cache?, #metadata, #ok?, #response_status

Methods inherited from Common::Base

#changed, #changed?, #changes, default_sort, filterable_attributes, max_per_page, per_page, sortable_attributes

Constructor Details

#initialize(status, response = nil) ⇒ BeneficiaryResponse

Returns a new instance of BeneficiaryResponse.



27
28
29
30
# File 'lib/evss/letters/beneficiary_response.rb', line 27

def initialize(status, response = nil)
  attributes = response.body if response
  super(status, attributes)
end

Instance Attribute Details

#benefit_informationEVSS::Letters::BenefitInformation

Returns The user’s benefit information.

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/evss/letters/beneficiary_response.rb', line 23

class BeneficiaryResponse < EVSS::Response
  attribute :benefit_information, EVSS::Letters::BenefitInformation
  attribute :military_service, Array[EVSS::Letters::MilitaryService]

  def initialize(status, response = nil)
    attributes = response.body if response
    super(status, attributes)
  end

  def benefit_information=(attrs)
    if veteran_attributes?(attrs)
      super EVSS::Letters::BenefitInformationVeteran.new(attrs)
    else
      super EVSS::Letters::BenefitInformationDependent.new(attrs)
    end
  end

  private

  def veteran_attributes?(attrs)
    attrs.key? 'has_service_connected_disabilities'
  end
end

#military_serviceObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/evss/letters/beneficiary_response.rb', line 23

class BeneficiaryResponse < EVSS::Response
  attribute :benefit_information, EVSS::Letters::BenefitInformation
  attribute :military_service, Array[EVSS::Letters::MilitaryService]

  def initialize(status, response = nil)
    attributes = response.body if response
    super(status, attributes)
  end

  def benefit_information=(attrs)
    if veteran_attributes?(attrs)
      super EVSS::Letters::BenefitInformationVeteran.new(attrs)
    else
      super EVSS::Letters::BenefitInformationDependent.new(attrs)
    end
  end

  private

  def veteran_attributes?(attrs)
    attrs.key? 'has_service_connected_disabilities'
  end
end