2018-09-04 18:19:29 +02:00
|
|
|
class CommentaireService
|
|
|
|
class << self
|
2018-11-29 15:00:26 +01:00
|
|
|
def build(sender, dossier, params)
|
|
|
|
case sender
|
|
|
|
when User
|
|
|
|
params[:user] = sender
|
|
|
|
when Gestionnaire
|
|
|
|
params[:gestionnaire] = sender
|
2018-09-04 18:19:29 +02:00
|
|
|
end
|
|
|
|
|
2018-11-29 15:00:26 +01:00
|
|
|
build_with_email(sender.email, dossier, params)
|
|
|
|
end
|
|
|
|
|
|
|
|
def build_with_email(email, dossier, params)
|
|
|
|
attributes = params.merge(email: email, dossier: dossier)
|
2018-09-04 18:19:29 +02:00
|
|
|
Commentaire.new(attributes)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|