Sha256: 1bb5cec87584b718bca6e35e5b8228ebe6b6af908b73ada55a3ce5e7c92eff4f

Contents?: true

Size: 948 Bytes

Versions: 5

Compression:

Stored size: 948 Bytes

Contents

module MessageTrain
  # Receipt mailer
  class ReceiptMailer < ApplicationMailer
    def notification_email(receipt)
      @receipt = receipt
      @recipient = receipt.recipient
      @through = receipt.received_through
      if @recipient == @through
        set_self_heading
      else
        set_through_heading
      end
      @subject = "#{@heading}: #{@receipt.message.subject}"
      mail(to: @recipient.email, subject: @subject)
    end

    private

    def set_self_heading
      @heading = :new_message_on_site_name.l(
        site_name: MessageTrain.configuration.site_name
      )
    end

    def set_through_heading
      @through_name = @through.send(
        MessageTrain.configuration.name_columns[
          @through.class.table_name.to_sym
        ]
      )
      @heading = :new_message_through_on_site_name.l(
        site_name: MessageTrain.configuration.site_name,
        through: @through_name
      )
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
message_train-0.7.6 app/mailers/message_train/receipt_mailer.rb
message_train-0.7.5 app/mailers/message_train/receipt_mailer.rb
message_train-0.7.3 app/mailers/message_train/receipt_mailer.rb
message_train-0.7.2 app/mailers/message_train/receipt_mailer.rb
message_train-0.7.1 app/mailers/message_train/receipt_mailer.rb