User clearer syntax for setting values when not already set

This commit is contained in:
Patrick Gansterer 2017-10-02 16:00:06 +02:00
parent 287cce2e92
commit e4b1280952

View file

@ -76,11 +76,11 @@ class Mailer < ActionMailer::Base
end end
def mail(args) def mail(args)
args[:message_id] = "#{Mail.random_tag}@#{default_url_options[:host]}" unless args[:message_id] args[:message_id] ||= "#{Mail.random_tag}@#{default_url_options[:host]}"
args[:subject] = "[#{FoodsoftConfig[:name]}] #{args[:subject]}" args[:subject] = "[#{FoodsoftConfig[:name]}] #{args[:subject]}"
if args[:from].is_a? User if args[:from].is_a? User
args[:reply_to] = args[:from] unless args[:reply_to] args[:reply_to] ||= args[:from]
args[:from] = "#{I18n.t('mailer.from_via_foodsoft', name: show_user(args[:from]))} <#{FoodsoftConfig[:email_sender]}>" args[:from] = "#{I18n.t('mailer.from_via_foodsoft', name: show_user(args[:from]))} <#{FoodsoftConfig[:email_sender]}>"
end end