-
-
Save walidvb/b02c7485bb2c9e578157ba5e55bd2c6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationMailer < ActionMailer::Base | |
def self.add_templates(template_names, block = -> {}) | |
template_names.each do |key| | |
define_method(key) do | |
end | |
end | |
define_method(:template_name, &block) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExportMailer < ApplicationMailer | |
add_templates Export.destinations.keys, -> { | |
# @export is nil, | |
# as this seems to be called from the class, not the instance of ExportMailer | |
@export.type | |
} | |
def send_export(export_id) | |
@export = Export.find(export_id) | |
@user = @export.user | |
mail(to: @user.email, subject: subject, template_name: template_name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment