Class: Caffeinate::CampaignSubscription
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Caffeinate::CampaignSubscription
- Defined in:
- app/models/caffeinate/campaign_subscription.rb
Overview
CampaignSubscription associates an object and its optional user to a Campaign and its relevant Mailings.
Instance Method Summary collapse
-
#deliver!(mailing) ⇒ Object
Actually deliver and process the mail.
-
#end! ⇒ Object
Updates ‘ended_at` and runs `on_complete` callbacks.
-
#ended? ⇒ Boolean
Checks if the CampaignSubscription is ended by checking the presence of ‘ended_at`.
-
#subscribed? ⇒ Boolean
Checks if the subscription is not ended and not unsubscribed.
-
#unsubscribe! ⇒ Object
Updates ‘unsubscribed_at` and runs `on_subscribe` callbacks.
-
#unsubscribed? ⇒ Boolean
Checks if the CampaignSubscription is not subscribed by checking the presence of ‘unsubscribed_at`.
Instance Method Details
#deliver!(mailing) ⇒ Object
Actually deliver and process the mail
48 49 50 |
# File 'app/models/caffeinate/campaign_subscription.rb', line 48 def deliver!(mailing) caffeinate_campaign.to_dripper.deliver!(mailing) end |
#end! ⇒ Object
Updates ‘ended_at` and runs `on_complete` callbacks
68 69 70 71 72 |
# File 'app/models/caffeinate/campaign_subscription.rb', line 68 def end! update!(ended_at: ::Caffeinate.config.time_now) caffeinate_campaign.to_dripper.run_callbacks(:on_complete, self) end |
#ended? ⇒ Boolean
Checks if the CampaignSubscription is ended by checking the presence of ‘ended_at`
63 64 65 |
# File 'app/models/caffeinate/campaign_subscription.rb', line 63 def ended? ended_at.present? end |
#subscribed? ⇒ Boolean
Checks if the subscription is not ended and not unsubscribed
53 54 55 |
# File 'app/models/caffeinate/campaign_subscription.rb', line 53 def subscribed? !ended? && !unsubscribed? end |
#unsubscribe! ⇒ Object
Updates ‘unsubscribed_at` and runs `on_subscribe` callbacks
75 76 77 78 79 |
# File 'app/models/caffeinate/campaign_subscription.rb', line 75 def unsubscribe! update!(unsubscribed_at: ::Caffeinate.config.time_now) caffeinate_campaign.to_dripper.run_callbacks(:on_unsubscribe, self) end |
#unsubscribed? ⇒ Boolean
Checks if the CampaignSubscription is not subscribed by checking the presence of ‘unsubscribed_at`
58 59 60 |
# File 'app/models/caffeinate/campaign_subscription.rb', line 58 def unsubscribed? unsubscribed_at.present? end |