Class: AhoyEmail::Tracker

Inherits:
Object
  • Object
show all
Defined in:
lib/ahoy_email/tracker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ Tracker

Returns a new instance of Tracker.



5
6
7
# File 'lib/ahoy_email/tracker.rb', line 5

def initialize(message)
  @message = message
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/ahoy_email/tracker.rb', line 3

def message
  @message
end

Instance Method Details

#performObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ahoy_email/tracker.rb', line 9

def perform
  Safely.safely do
    # perform_deliveries check still needed in observer
    if message.perform_deliveries
      if message.ahoy_data
        data = message.ahoy_data.merge(message: message)
        message.ahoy_message = AhoyEmail.track_method.call(data)
      end

      if message.ahoy_options && message.ahoy_options[:click]
        Utils.publish(:send, message.ahoy_options.slice(:campaign))
      end
    end
  end
end