Sha256: 1a25a4749ce1d0424a93685d150adc1ed789a341929d93600fdcc3112322541a

Contents?: true

Size: 861 Bytes

Versions: 4

Compression:

Stored size: 861 Bytes

Contents

module AhoyEmail
  module Mailer
    def self.included(base)
      base.extend ClassMethods
      base.prepend InstanceMethods
      base.class_eval do
        attr_accessor :ahoy_options
        class_attribute :ahoy_options
        self.ahoy_options = {}
      end
    end

    module ClassMethods
      def track(options = {})
        self.ahoy_options = ahoy_options.merge(message: true).merge(options)
      end
    end

    module InstanceMethods
      def track(options = {})
        self.ahoy_options = (ahoy_options || {}).merge(message: true).merge(options)
      end

      def mail(headers = {}, &block)
        # this mimics what original method does
        return message if @_mail_was_called && headers.blank? && !block

        message = super
        AhoyEmail::Processor.new(message, self).process
        message
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ahoy_email-0.5.2 lib/ahoy_email/mailer.rb
ahoy_email-0.4.0 lib/ahoy_email/mailer.rb
ahoy_email-0.3.2 lib/ahoy_email/mailer.rb
ahoy_email-0.3.1 lib/ahoy_email/mailer.rb