Class: Campagne::CampagneDelivery

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/campagne/campagne_delivery.rb

Instance Method Summary collapse

Instance Method Details

#bounce!Object



31
32
33
34
# File 'app/models/campagne/campagne_delivery.rb', line 31

def bounce!
  CampagneList.find(list_id).contacts.delete(CampagneContact.find(contact_id))
  update_attribute(:bounced_at, Time.now) if bounced_at.nil?
end

#click!(request) ⇒ Object



14
15
16
17
18
19
20
# File 'app/models/campagne/campagne_delivery.rb', line 14

def click!(request)
  self.ip_address = request.remote_ip if ip_address.blank?
  self.user_agent = request.user_agent if user_agent.blank?
  self.seen_at = Time.now if seen_at.nil?
  self.clicked_at = Time.now if clicked_at.nil?
  save
end

#see!(request) ⇒ Object



7
8
9
10
11
12
# File 'app/models/campagne/campagne_delivery.rb', line 7

def see!(request)
  self.ip_address = request.remote_ip if ip_address.blank?
  self.user_agent = request.user_agent if user_agent.blank?
  self.seen_at = Time.now if seen_at.nil?
  save
end

#unsubscribe!(request) ⇒ Object



22
23
24
25
26
27
28
29
# File 'app/models/campagne/campagne_delivery.rb', line 22

def unsubscribe!(request)
  CampagneList.find(list_id).contacts.delete(CampagneContact.find(contact_id)) # Remove contact from list
  self.ip_address = request.remote_ip if ip_address.blank?
  self.user_agent = request.user_agent if user_agent.blank?
  self.seen_at = Time.now if seen_at.nil?
  self.unsubscribed_at = Time.now if unsubscribed_at.nil?
  save
end