Mutualize the adapters’ #data_source methods

This commit is contained in:
gregoirenovel 2018-03-19 15:05:56 +01:00
parent a9360a8be2
commit 68c9849977
5 changed files with 14 additions and 16 deletions

View file

@ -3,4 +3,10 @@ class ApiEntreprise::Adapter
@siret_or_siren = siret_or_siren
@procedure_id = procedure_id
end
def data_source
@data_source ||= get_resource
rescue
@data_source = nil
end
end

View file

@ -11,10 +11,8 @@ class ApiEntreprise::EntrepriseAdapter < ApiEntreprise::Adapter
private
def data_source
@data_source ||= ApiEntreprise::API.entreprise(@siret_or_siren, @procedure_id)
rescue
@data_source = nil
def get_resource
ApiEntreprise::API.entreprise(@siret_or_siren, @procedure_id)
end
def attr_to_fetch

View file

@ -13,10 +13,8 @@ class ApiEntreprise::EtablissementAdapter < ApiEntreprise::Adapter
private
def data_source
@data_source ||= ApiEntreprise::API.etablissement(@siret_or_siren, @procedure_id)
rescue
@data_source = nil
def get_resource
ApiEntreprise::API.etablissement(@siret_or_siren, @procedure_id)
end
def attr_to_fetch

View file

@ -11,10 +11,8 @@ class ApiEntreprise::ExercicesAdapter < ApiEntreprise::Adapter
private
def data_source
@data_source ||= ApiEntreprise::API.exercices(@siret_or_siren, @procedure_id)
rescue
@data_source = nil
def get_resource
ApiEntreprise::API.exercices(@siret_or_siren, @procedure_id)
end
def attr_to_fetch

View file

@ -11,10 +11,8 @@ class ApiEntreprise::RNAAdapter < ApiEntreprise::Adapter
private
def data_source
@data_source ||= ApiEntreprise::API.rna(@siret_or_siren, @procedure_id)
rescue
@data_source = nil
def get_resource
ApiEntreprise::API.rna(@siret_or_siren, @procedure_id)
end
def attr_to_fetch