Module: Moist::Models::CampaignSubscriber
- Included in:
- CampaignSubscriber
- Defined in:
- lib/moist/models/campaign_subscriber.rb
Class Method Summary collapse
Instance Method Summary collapse
- #current_step ⇒ Object
- #mail! ⇒ Object
- #next_mailing ⇒ Object
- #next_step ⇒ Object
- #next_step? ⇒ Boolean
- #ready_for_next_mailing? ⇒ Boolean
Class Method Details
.included(klass) ⇒ Object
4 5 6 |
# File 'lib/moist/models/campaign_subscriber.rb', line 4 def self.included(klass) # klass.extend ClassMethods end |
Instance Method Details
#current_step ⇒ Object
8 9 10 |
# File 'lib/moist/models/campaign_subscriber.rb', line 8 def current_step most_recent_moist_mailing end |
#mail! ⇒ Object
32 33 34 |
# File 'lib/moist/models/campaign_subscriber.rb', line 32 def mail! next_mailing.deliver! end |
#next_mailing ⇒ Object
16 17 18 19 20 |
# File 'lib/moist/models/campaign_subscriber.rb', line 16 def next_mailing return nil unless next_step moist_mailings.find_by(mailer_class: next_step.mailer_class, mailer_action: next_step.mailer_action) end |
#next_step ⇒ Object
12 13 14 |
# File 'lib/moist/models/campaign_subscriber.rb', line 12 def next_step next_moist_mailing || raise(::Moist::CampaignComplete) end |
#next_step? ⇒ Boolean
22 23 24 |
# File 'lib/moist/models/campaign_subscriber.rb', line 22 def next_step? next_moist_mailing.present? end |
#ready_for_next_mailing? ⇒ Boolean
26 27 28 29 30 |
# File 'lib/moist/models/campaign_subscriber.rb', line 26 def ready_for_next_mailing? return false unless next_mailing next_mailing.send_at < Time.current end |