Class: AhoyEmail::MessageSubscriber

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

Instance Method Summary collapse

Instance Method Details

#track_click(event) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/ahoy_email/message_subscriber.rb', line 3

def track_click(event)
  message = AhoyEmail.message_model.find_by(token: event[:token])
  if message
    message.clicked ||= true if message.respond_to?(:clicked=)
    message.clicked_at ||= Time.now if message.respond_to?(:clicked_at=)
    message.save! if message.changed?
  end
end