Reduce method calls
This commit is contained in:
parent
8b46df3176
commit
b479833699
1 changed files with 5 additions and 5 deletions
|
@ -6,13 +6,13 @@ class SIRETService
|
|||
entreprise_params = ApiEntreprise::EntrepriseAdapter.new(siren(siret), procedure_id).to_params
|
||||
|
||||
if etablissement_params.present? && entreprise_params.present?
|
||||
association = ApiEntreprise::RNAAdapter.new(siret, procedure_id)
|
||||
exercices = ApiEntreprise::ExercicesAdapter.new(siret, procedure_id)
|
||||
association_params = ApiEntreprise::RNAAdapter.new(siret, procedure_id).to_params
|
||||
exercices_array = ApiEntreprise::ExercicesAdapter.new(siret, procedure_id).to_array
|
||||
|
||||
params = etablissement_params
|
||||
.merge(entreprise_params.map { |k,v| ["entreprise_#{k}", v] }.to_h)
|
||||
.merge(association.to_params&.map { |k,v| ["association_#{k}", v] }.to_h)
|
||||
.merge(exercices_attributes: exercices.to_array)
|
||||
.merge(association_params&.map { |k,v| ["association_#{k}", v] }.to_h)
|
||||
.merge(exercices_attributes: exercices_array)
|
||||
|
||||
# This is to fill legacy models and relationships
|
||||
if dossier.present?
|
||||
|
@ -20,7 +20,7 @@ class SIRETService
|
|||
entreprise_attributes: entreprise_params
|
||||
.merge({
|
||||
dossier: dossier,
|
||||
rna_information_attributes: association.to_params
|
||||
rna_information_attributes: association_params
|
||||
}.compact)
|
||||
)
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue