module Vanity::Rails::UseVanityMailer
Protected Instance Methods
use_vanity_mailer(symbol = nil)
click to toggle source
Should be called from within the mailer function. For example:
def invite_email(user) use_vanity_mailer user mail to: user.email, subject: ab_test(:invite_subject) end
# File lib/vanity/frameworks/rails.rb, line 115 def use_vanity_mailer(symbol = nil) # Context is the instance of ActionMailer::Base Vanity.context = self if symbol && (@object = symbol) class << self define_method :vanity_identity do @vanity_identity = (String === @object ? @object : @object.id) end end else class << self define_method :vanity_identity do @vanity_identity = @vanity_identity || SecureRandom.hex(16) end end end end