demarches-normaliennes/app/models/concerns/mail_template_concern.rb

25 lines
632 B
Ruby
Raw Normal View History

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)
2017-05-27 01:16:38 +02:00
body = ActionController::Base.new.render_to_string(template: self.const_get(:TEMPLATE_NAME))
self.new(subject: self.const_get(:DEFAULT_SUBJECT), body: body, procedure: procedure)
end
end
def dossier_tags
TagsSubstitutionConcern::DOSSIER_TAGS + TagsSubstitutionConcern::DOSSIER_TAGS_FOR_MAIL
end
end