Module: Caffeinate::Dripper::Callbacks::ClassMethods
- Defined in:
- lib/caffeinate/dripper/callbacks.rb
Instance Method Summary collapse
-
#after_perform { ... } ⇒ Object
Callback after the all the mailings have been sent.
-
#after_perform_blocks ⇒ Object
:nodoc:.
-
#after_send { ... } ⇒ Object
Callback after a Mailing has been sent.
-
#after_send_blocks ⇒ Object
:nodoc:.
-
#before_drip { ... } ⇒ Object
Callback before a Drip has called the mailer.
-
#before_drip_blocks ⇒ Object
:nodoc:.
-
#before_perform { ... } ⇒ Object
Callback before the mailings get processed.
-
#before_perform_blocks ⇒ Object
:nodoc:.
-
#before_send { ... } ⇒ Object
Callback before a Mailing has been sent.
-
#before_send_blocks ⇒ Object
:nodoc:.
-
#on_complete { ... } ⇒ Object
Callback after a CampaignSubscriber has exhausted all their mailings.
-
#on_complete_blocks ⇒ Object
:nodoc:.
-
#on_end { ... } ⇒ Object
Callback after a CampaignSubscriber has ended.
-
#on_end_blocks ⇒ Object
:nodoc:.
-
#on_perform { ... } ⇒ Object
Callback before the mailings get processed in a batch.
-
#on_perform_blocks ⇒ Object
:nodoc:.
-
#on_resubscribe { ... } ⇒ Object
Callback after a Caffeinate::CampaignSubscription is
#resubscribed!. -
#on_resubscribe_blocks ⇒ Object
:nodoc:.
-
#on_skip { ... } ⇒ Object
Callback after a
Caffeinate::Mailingis skipped. -
#on_skip_blocks ⇒ Object
:nodoc:.
-
#on_subscribe { ... } ⇒ Object
Callback after a Caffeinate::CampaignSubscription is created, and after the Caffeinate::Mailings have been created.
-
#on_subscribe_blocks ⇒ Object
:nodoc:.
-
#on_unsubscribe { ... } ⇒ Object
Callback after a CampaignSubscriber has unsubscribed.
-
#on_unsubscribe_blocks ⇒ Object
:nodoc:.
-
#run_callbacks(name, *args) ⇒ Object
:nodoc:.
Instance Method Details
#after_perform { ... } ⇒ Object
Callback after the all the mailings have been sent.
after_process do |dripper|
Slack.notify(:caffeinate, "Dripper #{dripper.name} sent #{mailings.size} mailings! Whoa!")
end
98 99 100 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 98 def after_perform(&block) after_perform_blocks << block end |
#after_perform_blocks ⇒ Object
:nodoc:
103 104 105 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 103 def after_perform_blocks @after_perform_blocks ||= [] end |
#after_send { ... } ⇒ Object
Callback after a Mailing has been sent.
after_send do |campaign_subscription, mailing, |
Slack.notify(:caffeinate, "A new subscriber to #{campaign_subscription.campaign.name}!")
end
149 150 151 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 149 def after_send(&block) after_send_blocks << block end |
#after_send_blocks ⇒ Object
:nodoc:
154 155 156 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 154 def after_send_blocks @after_send_blocks ||= [] end |
#before_drip { ... } ⇒ Object
Callback before a Drip has called the mailer.
before_drip do |campaign_subscription, mailing, drip|
Slack.notify(:caffeinate, "#{drip.action_name} is starting")
end
115 116 117 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 115 def before_drip(&block) before_drip_blocks << block end |
#before_drip_blocks ⇒ Object
:nodoc:
120 121 122 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 120 def before_drip_blocks @before_drip_blocks ||= [] end |
#before_perform { ... } ⇒ Object
Callback before the mailings get processed.
before_perform do |dripper|
Slack.notify(:caffeinate, "Dripper is getting ready for mailing! #{dripper.caffeinate_campaign.name}!")
end
64 65 66 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 64 def before_perform(&block) before_perform_blocks << block end |
#before_perform_blocks ⇒ Object
:nodoc:
69 70 71 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 69 def before_perform_blocks @before_perform_blocks ||= [] end |
#before_send { ... } ⇒ Object
Callback before a Mailing has been sent.
before_send do |campaign_subscription, mailing, |
Slack.notify(:caffeinate, "A new subscriber to #{campaign_subscription.campaign.name}!")
end
132 133 134 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 132 def before_send(&block) before_send_blocks << block end |
#before_send_blocks ⇒ Object
:nodoc:
137 138 139 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 137 def before_send_blocks @before_send_blocks ||= [] end |
#on_complete { ... } ⇒ Object
Callback after a CampaignSubscriber has exhausted all their mailings.
on_complete do |campaign_sub|
Slack.notify(:caffeinate, "A subscriber completed #{campaign_sub.campaign.name}!")
end
165 166 167 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 165 def on_complete(&block) on_complete_blocks << block end |
#on_complete_blocks ⇒ Object
:nodoc:
170 171 172 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 170 def on_complete_blocks @on_complete_blocks ||= [] end |
#on_end { ... } ⇒ Object
Callback after a CampaignSubscriber has ended.
on_end do |campaign_sub|
Slack.notify(:caffeinate, "#{campaign_sub.id} has ended... sad day.")
end
197 198 199 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 197 def on_end(&block) on_end_blocks << block end |
#on_end_blocks ⇒ Object
:nodoc:
202 203 204 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 202 def on_end_blocks @on_end_blocks ||= [] end |
#on_perform { ... } ⇒ Object
Callback before the mailings get processed in a batch.
after_process do |dripper, mailings|
Slack.notify(:caffeinate, "Dripper #{dripper.name} sent #{mailings.size} mailings! Whoa!")
end
81 82 83 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 81 def on_perform(&block) on_perform_blocks << block end |
#on_perform_blocks ⇒ Object
:nodoc:
86 87 88 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 86 def on_perform_blocks @on_perform_blocks ||= [] end |
#on_resubscribe { ... } ⇒ Object
Callback after a Caffeinate::CampaignSubscription is #resubscribed!
on_resubscribe do |campaign_subscription|
Slack.notify(:caffeinate, "Someone resubscribed to #{campaign_subscription.campaign.name}!")
end
48 49 50 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 48 def on_resubscribe(&block) on_resubscribe_blocks << block end |
#on_resubscribe_blocks ⇒ Object
:nodoc:
53 54 55 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 53 def on_resubscribe_blocks @on_resubscribe_blocks ||= [] end |
#on_skip { ... } ⇒ Object
Callback after a Caffeinate::Mailing is skipped.
on_skip do |campaign_subscription, mailing, |
Slack.notify(:caffeinate, "#{campaign_sub.id} has unsubscribed... sad day.")
end
213 214 215 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 213 def on_skip(&block) on_skip_blocks << block end |
#on_skip_blocks ⇒ Object
:nodoc:
218 219 220 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 218 def on_skip_blocks @on_skip_blocks ||= [] end |
#on_subscribe { ... } ⇒ Object
Callback after a Caffeinate::CampaignSubscription is created, and after the Caffeinate::Mailings have been created.
on_subscribe do |campaign_subscription|
Slack.notify(:caffeinate, "A new subscriber to #{campaign_subscription.campaign.name}!")
end
32 33 34 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 32 def on_subscribe(&block) on_subscribe_blocks << block end |
#on_subscribe_blocks ⇒ Object
:nodoc:
37 38 39 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 37 def on_subscribe_blocks @on_subscribe_blocks ||= [] end |
#on_unsubscribe { ... } ⇒ Object
Callback after a CampaignSubscriber has unsubscribed.
on_unsubscribe do |campaign_sub|
Slack.notify(:caffeinate, "#{campaign_sub.id} has unsubscribed... sad day.")
end
181 182 183 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 181 def on_unsubscribe(&block) on_unsubscribe_blocks << block end |
#on_unsubscribe_blocks ⇒ Object
:nodoc:
186 187 188 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 186 def on_unsubscribe_blocks @on_unsubscribe_blocks ||= [] end |
#run_callbacks(name, *args) ⇒ Object
:nodoc:
18 19 20 21 22 |
# File 'lib/caffeinate/dripper/callbacks.rb', line 18 def run_callbacks(name, *args) send("#{name}_blocks").each do |callback| callback.call(*args) end end |