Module: Moist::Models::CampaignSubscriber

Included in:
CampaignSubscriber
Defined in:
lib/moist/models/campaign_subscriber.rb

Class Method Summary collapse

Instance Method Summary collapse

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_stepObject



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_mailingObject



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_stepObject



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

Returns:

  • (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

Returns:

  • (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