Sha256: 070873e277590e0416a44fe39b2452a824fcc0002a65373a50f4e373a1143fea

Contents?: true

Size: 765 Bytes

Versions: 2

Compression:

Stored size: 765 Bytes

Contents

require 'mandrill'
require 'letter_opener'

module MandrillLetterOpener
  class Engine < ::Rails::Engine
    initializer 'mandrill_letter_opener', group: :all  do |app|
      if config.action_mailer[:delivery_method] == :letter_opener
        MandrillMailer::TemplateMailer.class_eval do
          define_method :deliver do
            opts = {
                from: message['from_email'],
                to: message['to'].map{|m| m['email']}.join(', '),
                subject: message['subject'],
                body: JSON.pretty_generate(message)
            }
            ActionMailer::Base.mail(opts).deliver
          end
          alias_method :deliver_now, :deliver
          alias_method :deliver_later, :deliver
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mandrill_letter_opener-0.2.0 lib/mandrill_letter_opener/engine.rb
mandrill_letter_opener-0.1.0 lib/mandrill_letter_opener/engine.rb