Module: AhoyEmail::Mailer

Extended by:
ActiveSupport::Concern
Defined in:
lib/ahoy_email/mailer.rb

Instance Method Summary collapse

Instance Method Details

#ahoy_optionsObject



22
23
24
# File 'lib/ahoy_email/mailer.rb', line 22

def ahoy_options
  @ahoy_options ||= AhoyEmail.default_options
end

#save_ahoy_optionsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ahoy_email/mailer.rb', line 26

def save_ahoy_options
  Safely.safely do
    # do message first for performance
    message = ahoy_options[:message]
    message = message.respond_to?(:call) ? instance_exec(&message) : message

    if message
      options = {}
      ahoy_options.except(:message).each do |k, v|
        # execute options in mailer content
        options[k] = v.respond_to?(:call) ? instance_exec(&v) : v
      end

      AhoyEmail::Processor.new(self, options).perform
    end
  end
end

#track(**options) ⇒ Object



18
19
20
# File 'lib/ahoy_email/mailer.rb', line 18

def track(**options)
  self.ahoy_options = ahoy_options.merge(message: true).merge(options)
end