Simplify RNAAdapter#process_params

Avoid catching an attribute only to remove it
a few lines later
This commit is contained in:
gregoirenovel 2018-10-04 18:48:33 +02:00
parent b28607a3a6
commit 1ffd4a230b

View file

@ -12,11 +12,12 @@ class ApiEntreprise::RNAAdapter < ApiEntreprise::Adapter
if !data_source.key?(:association)
{}
else
association_id = data_source[:association][:id]
params = data_source[:association].slice(*attr_to_fetch)
if params[:id].present? && valid_params?(params)
params[:rna] = params[:id]
params.except(:id).transform_keys { |k| :"association_#{k}" }
if association_id.present? && valid_params?(params)
params[:rna] = association_id
params.transform_keys { |k| :"association_#{k}" }
else
{}
end
@ -25,7 +26,6 @@ class ApiEntreprise::RNAAdapter < ApiEntreprise::Adapter
def attr_to_fetch
[
:id,
:titre,
:objet,
:date_creation,