Sha256: 2087ee0bd3b22686a235ce058b8e50b284638f10a3f9420f48ecf8e3f50b01b5
Contents?: true
Size: 1.18 KB
Versions: 3
Compression:
Stored size: 1.18 KB
Contents
require "aasm" module Chaskiq class Subscription < ActiveRecord::Base belongs_to :subscriber belongs_to :list has_many :campaigns, through: :list has_many :metrics , as: :trackable delegate :name, :last_name, :email, to: :subscriber scope :availables, ->{ where(["chaskiq_subscriptions.state =? or chaskiq_subscriptions.state=?", "passive", "subscribed"]) } include AASM aasm :column => :state do # default column: aasm_state state :passive, :initial => true state :subscribed, :after_enter => :notify_subscription state :unsubscribed, :after_enter => :notify_unsubscription #state :bounced, :after_enter => :make_bounced #state :complained, :after_enter => :make_complained event :subscribe do transitions :from => [:passive, :unsubscribed], :to => :subscribed end event :unsubscribe do transitions :from => [:subscribed, :passive], :to => :unsubscribed end end def notify_unsubscription puts "Pending" end def notify_subscription #we should only unsubscribe when process is made from interface, not from sns notification puts "Pending" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
chaskiq-0.0.6 | app/models/chaskiq/subscription.rb |
chaskiq-0.0.5 | app/models/chaskiq/subscription.rb |
chaskiq-0.0.4 | app/models/chaskiq/subscription.rb |