Sha256: 966248bab3baeb3590b83b5b1f767b5eb7ec7c932a1e692f6600cad504ffe06f

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

module Campagne
  class CampagneDelivery < ActiveRecord::Base
    belongs_to :campagne_campaign

    attr_accessible :contact_id, :campagne_list_id , :email, :token

    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

    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

    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

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

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
campagne-0.2.2 app/models/campagne/campagne_delivery.rb
campagne-0.2.0 app/models/campagne/campagne_delivery.rb
campagne-0.1.2 app/models/campagne/campagne_delivery.rb
campagne-0.1.1 app/models/campagne/campagne_delivery.rb
campagne-0.1.0 app/models/campagne/campagne_delivery.rb
campagne-0.0.2 app/models/campagne/campagne_delivery.rb