Sha256: d7fd212cef827e2029051ea4c77b49d91d304206e7b1acfb1adfa507d0fe5d22

Contents?: true

Size: 850 Bytes

Versions: 1

Compression:

Stored size: 850 Bytes

Contents

module AhoyEmail
  module Mailer
    def self.included(base)
      base.extend ClassMethods
      base.class_eval do
        attr_accessor :ahoy_options
        class_attribute :ahoy_options
        self.ahoy_options = {}
        alias_method_chain :mail, :ahoy
      end
    end

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

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

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

      message = mail_without_ahoy(headers, &block)
      AhoyEmail::Processor.new(message, self).process
      message
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ahoy_email-0.3.0 lib/ahoy_email/mailer.rb