demarches-normaliennes/app/models/concerns/mail_template_concern.rb
2018-04-04 10:44:40 +02:00

24 lines
625 B
Ruby

module MailTemplateConcern
extend ActiveSupport::Concern
include TagsSubstitutionConcern
def subject_for_dossier(dossier)
replace_tags(subject, dossier)
end
def body_for_dossier(dossier)
replace_tags(body, dossier)
end
module ClassMethods
def default_for_procedure(procedure)
body = ActionController::Base.new.render_to_string(template: const_get(:DEFAULT_TEMPLATE_NAME))
new(subject: const_get(:DEFAULT_SUBJECT), body: body, procedure: procedure)
end
end
def dossier_tags
TagsSubstitutionConcern::DOSSIER_TAGS + TagsSubstitutionConcern::DOSSIER_TAGS_FOR_MAIL
end
end