mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-18 04:39:14 +00:00
It has the advantage that `rails generate mailer` works out of the box and we comply with rubocop rules.
20 lines
565 B
Ruby
20 lines
565 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Spree
|
|
class ShipmentMailer < ApplicationMailer
|
|
def shipped_email(shipment, delivery:)
|
|
@shipment = shipment.respond_to?(:id) ? shipment : Spree::Shipment.find(shipment)
|
|
@delivery = delivery
|
|
subject = base_subject
|
|
mail(to: @shipment.order.email, subject: subject)
|
|
end
|
|
|
|
private
|
|
|
|
def base_subject
|
|
default_subject = !@delivery ? t('.picked_up_subject') : default_i18n_subject
|
|
"#{@shipment.order.distributor.name} #{default_subject} ##{@shipment.order.number}"
|
|
end
|
|
end
|
|
end
|