Sha256: d06bcf89b3412aef1e01062bcff5014fffa9a0aec0dc3c3fc008e2d4d9c04e84

Contents?: true

Size: 458 Bytes

Versions: 1

Compression:

Stored size: 458 Bytes

Contents

module SidekiqSendMail
  class MailInterceptor
    def self.delivering_email(message)
      unless deliver?(message)
        Sidekiq::Client.push 'queue' => 'emails', 'class' => 'SidekiqSendMail::Worker', 'args' => [message.to_yaml]
        message.perform_deliveries = false
        puts "Mail routed to Sidekiq (#{message.subject})!"
      end
    end

    def self.deliver?(message)
      defined?(Sidekiq::CLI) #Rails.env.development?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidekiq_send_mail-0.1.0 lib/mail_interceptor.rb