Sha256: acd037b6521a64000628937af14546036c3e608103e555af211745723488201a

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

require "ahoy_email/version"
require "action_mailer"
require "rails"
require "nokogiri"
require "addressable/uri"
require "openssl"
require "safely_block"
require "ahoy_email/processor"
require "ahoy_email/interceptor"
require "ahoy_email/mailer"
require "ahoy_email/engine"

module AhoyEmail
  mattr_accessor :secret_token, :options, :subscribers

  self.options = {
    message: true,
    open: true,
    click: true,
    utm_params: true,
    utm_source: proc { |message, mailer| mailer.mailer_name },
    utm_medium: "email",
    utm_term: nil,
    utm_content: nil,
    utm_campaign: proc { |message, mailer| mailer.action_name },
    user: proc { |message, mailer| (message.to.size == 1 ? User.where(email: message.to.first).first : nil) rescue nil },
    mailer: proc { |message, mailer| "#{mailer.class.name}##{mailer.action_name}" },
    url_options: {}
  }

  self.subscribers = []

  def self.track(options)
    self.options = self.options.merge(options)
  end

  class << self
    attr_writer :message_model
  end

  def self.message_model
    @message_model || Ahoy::Message
  end
end

ActionMailer::Base.send :include, AhoyEmail::Mailer
ActionMailer::Base.register_interceptor AhoyEmail::Interceptor

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ahoy_email-0.3.2 lib/ahoy_email.rb
ahoy_email-0.3.1 lib/ahoy_email.rb
ahoy_email-0.3.0 lib/ahoy_email.rb