Class: Caffeinate::DripEvaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/caffeinate/drip_evaluator.rb

Overview

Handles evaluating the ‘drip` block and provides convenience methods for handling the mailing or its campaign.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mailing) ⇒ DripEvaluator

Returns a new instance of DripEvaluator.



8
9
10
# File 'lib/caffeinate/drip_evaluator.rb', line 8

def initialize(mailing)
  @mailing = mailing
end

Instance Attribute Details

#mailingObject (readonly)

Returns the value of attribute mailing.



6
7
8
# File 'lib/caffeinate/drip_evaluator.rb', line 6

def mailing
  @mailing
end

Instance Method Details

#call(&block) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/caffeinate/drip_evaluator.rb', line 12

def call(&block)
  return true unless block
  catch(:abort) do
    result = instance_eval(&block)
    return result.nil? || result === true
  end
  false
end

#end!(*args) ⇒ Object

Ends the CampaignSubscription



22
23
24
25
# File 'lib/caffeinate/drip_evaluator.rb', line 22

def end!(*args)
  mailing.caffeinate_campaign_subscription.end!(*args)
  throw(:abort)
end

#skip!Object

Skips the mailing



34
35
36
37
# File 'lib/caffeinate/drip_evaluator.rb', line 34

def skip!
  mailing.skip!
  throw(:abort)
end

#unsubscribe!(*args) ⇒ Object

Unsubscribes the CampaignSubscription



28
29
30
31
# File 'lib/caffeinate/drip_evaluator.rb', line 28

def unsubscribe!(*args)
  mailing.caffeinate_campaign_subscription.unsubscribe!(*args)
  throw(:abort)
end