Sha256: b9a2172f2f53951e93a2e995feed5ddadd2764264b6ceb2f168ea4f69ad0dfa0

Contents?: true

Size: 869 Bytes

Versions: 6

Compression:

Stored size: 869 Bytes

Contents

module AhoyEmail
  module Mailer

    def self.included(base)
      base.extend ClassMethods
      base.class_eval do
        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(options)
      end
    end

    def track(options)
      @ahoy_options = (@ahoy_options || {}).merge(options)
    end

    def mail_with_ahoy(headers = {}, &block)
      message = mail_without_ahoy(headers, &block)

      options = AhoyEmail.options.merge(self.class.ahoy_options).merge(@ahoy_options || {})
      options.each do |k, v|
        if v.respond_to?(:call)
          options[k] = v.call(message, self)
        end
      end
      AhoyEmail::Processor.new(message, options).process

      message
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ahoy_email-0.1.5 lib/ahoy_email/mailer.rb
ahoy_email-0.1.4 lib/ahoy_email/mailer.rb
ahoy_email-0.1.3 lib/ahoy_email/mailer.rb
ahoy_email-0.1.2 lib/ahoy_email/mailer.rb
ahoy_email-0.1.1 lib/ahoy_email/mailer.rb
ahoy_email-0.1.0 lib/ahoy_email/mailer.rb