Class: BGS::VnpRelationships

Inherits:
Object
  • Object
show all
Defined in:
lib/bgs/vnp_relationships.rb

Instance Method Summary collapse

Constructor Details

#initialize(proc_id:, veteran:, step_children:, dependents:, user:) ⇒ VnpRelationships

Returns a new instance of VnpRelationships.



7
8
9
10
11
12
13
# File 'lib/bgs/vnp_relationships.rb', line 7

def initialize(proc_id:, veteran:, step_children:, dependents:, user:)
  @user = user
  @veteran = veteran
  @proc_id = proc_id
  @step_children = step_children
  @dependents = dependents
end

Instance Method Details

#create_allObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bgs/vnp_relationships.rb', line 15

def create_all
  spouse_marriages, vet_dependents = @dependents.partition do |dependent|
    dependent[:type] == 'spouse_marriage_history'
  end

  spouse = @dependents.find { |dependent| dependent[:type] == 'spouse' }

  send_step_children_relationships if @step_children.present?
  send_spouse_marriage_history_relationships(spouse, spouse_marriages)
  send_vet_dependent_relationships(vet_dependents)
end