Sha256: e25515c02eb0d9b8eb1288544736d58fe5e0eebd249ab0f2088373e6c1b85e08

Contents?: true

Size: 869 Bytes

Versions: 2

Compression:

Stored size: 869 Bytes

Contents

module AhoyEmail
  module Mailer
    def self.included(base)
      base.extend ClassMethods
      base.send(: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

2 entries across 2 versions & 1 rubygems

Version Path
ahoy_email-0.5.1 lib/ahoy_email/mailer.rb
ahoy_email-0.5.0 lib/ahoy_email/mailer.rb