Class: Preneeds::ServiceRecord

Inherits:
Base
  • Object
show all
Defined in:
app/models/preneeds/service_record.rb

Overview

Models service record information for a BurialForm form

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#as_json

Methods included from Vets::Model

#attributes, #initialize, #nested_attributes

Methods included from Vets::Attributes

included

Instance Attribute Details

#date_rangePreneeds::DateRange

Returns service date range.

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/models/preneeds/service_record.rb', line 17

class ServiceRecord < Preneeds::Base
  attribute :service_branch, String
  attribute :discharge_type, String
  attribute :highest_rank, String
  attribute :national_guard_state, String

  attribute :date_range, Preneeds::DateRange

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      branchOfService: service_branch, dischargeType: discharge_type,
      enteredOnDutyDate: date_range.try(:from), highestRank: highest_rank,
      nationalGuardState: national_guard_state, releaseFromDutyDate: date_range.try(:to)
    }

    %i[
      enteredOnDutyDate releaseFromDutyDate highestRank nationalGuardState dischargeType
    ].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    [
      :service_branch, :discharge_type, :highest_rank, :national_guard_state,
      { date_range: Preneeds::DateRange.permitted_params }
    ]
  end
end

#discharge_typeObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/models/preneeds/service_record.rb', line 17

class ServiceRecord < Preneeds::Base
  attribute :service_branch, String
  attribute :discharge_type, String
  attribute :highest_rank, String
  attribute :national_guard_state, String

  attribute :date_range, Preneeds::DateRange

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      branchOfService: service_branch, dischargeType: discharge_type,
      enteredOnDutyDate: date_range.try(:from), highestRank: highest_rank,
      nationalGuardState: national_guard_state, releaseFromDutyDate: date_range.try(:to)
    }

    %i[
      enteredOnDutyDate releaseFromDutyDate highestRank nationalGuardState dischargeType
    ].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    [
      :service_branch, :discharge_type, :highest_rank, :national_guard_state,
      { date_range: Preneeds::DateRange.permitted_params }
    ]
  end
end

#highest_rankString

Returns highest rank achieved.

Returns:

  • (String)

    highest rank achieved



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/models/preneeds/service_record.rb', line 17

class ServiceRecord < Preneeds::Base
  attribute :service_branch, String
  attribute :discharge_type, String
  attribute :highest_rank, String
  attribute :national_guard_state, String

  attribute :date_range, Preneeds::DateRange

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      branchOfService: service_branch, dischargeType: discharge_type,
      enteredOnDutyDate: date_range.try(:from), highestRank: highest_rank,
      nationalGuardState: national_guard_state, releaseFromDutyDate: date_range.try(:to)
    }

    %i[
      enteredOnDutyDate releaseFromDutyDate highestRank nationalGuardState dischargeType
    ].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    [
      :service_branch, :discharge_type, :highest_rank, :national_guard_state,
      { date_range: Preneeds::DateRange.permitted_params }
    ]
  end
end

#national_guard_stateString

Returns state - for national guard service only.

Returns:

  • (String)

    state - for national guard service only



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/models/preneeds/service_record.rb', line 17

class ServiceRecord < Preneeds::Base
  attribute :service_branch, String
  attribute :discharge_type, String
  attribute :highest_rank, String
  attribute :national_guard_state, String

  attribute :date_range, Preneeds::DateRange

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      branchOfService: service_branch, dischargeType: discharge_type,
      enteredOnDutyDate: date_range.try(:from), highestRank: highest_rank,
      nationalGuardState: national_guard_state, releaseFromDutyDate: date_range.try(:to)
    }

    %i[
      enteredOnDutyDate releaseFromDutyDate highestRank nationalGuardState dischargeType
    ].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    [
      :service_branch, :discharge_type, :highest_rank, :national_guard_state,
      { date_range: Preneeds::DateRange.permitted_params }
    ]
  end
end

#service_branchObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/models/preneeds/service_record.rb', line 17

class ServiceRecord < Preneeds::Base
  attribute :service_branch, String
  attribute :discharge_type, String
  attribute :highest_rank, String
  attribute :national_guard_state, String

  attribute :date_range, Preneeds::DateRange

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      branchOfService: service_branch, dischargeType: discharge_type,
      enteredOnDutyDate: date_range.try(:from), highestRank: highest_rank,
      nationalGuardState: national_guard_state, releaseFromDutyDate: date_range.try(:to)
    }

    %i[
      enteredOnDutyDate releaseFromDutyDate highestRank nationalGuardState dischargeType
    ].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    [
      :service_branch, :discharge_type, :highest_rank, :national_guard_state,
      { date_range: Preneeds::DateRange.permitted_params }
    ]
  end
end

Class Method Details

.permitted_paramsArray

List of permitted params for use with Strong Parameters

Returns:

  • (Array)

    array of class attributes as symbols



45
46
47
48
49
50
# File 'app/models/preneeds/service_record.rb', line 45

def self.permitted_params
  [
    :service_branch, :discharge_type, :highest_rank, :national_guard_state,
    { date_range: Preneeds::DateRange.permitted_params }
  ]
end

Instance Method Details

#as_eoasHash

Converts object attributes to a hash to be used when constructing a SOAP request body. Hash attributes must correspond to XSD ordering or API call will fail

Returns:

  • (Hash)

    object attributes and association objects converted to EOAS service compatible hash



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/preneeds/service_record.rb', line 27

def as_eoas
  hash = {
    branchOfService: service_branch, dischargeType: discharge_type,
    enteredOnDutyDate: date_range.try(:from), highestRank: highest_rank,
    nationalGuardState: national_guard_state, releaseFromDutyDate: date_range.try(:to)
  }

  %i[
    enteredOnDutyDate releaseFromDutyDate highestRank nationalGuardState dischargeType
  ].each do |key|
    hash.delete(key) if hash[key].blank?
  end

  hash
end