Class: Caffeinate::Configuration

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

Overview

Global configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/caffeinate/configuration.rb', line 43

def initialize
  @now = -> { Time.current }
  @async_delivery = false
  @deliver_later = false
  @async_delivery_class = nil
  @batch_size = 1_000
  @drippers_path = 'app/drippers'
  @implicit_campaigns = true
  @default_ended_reason = nil
  @default_unsubscribe_reason = nil
  @enabled_drippers = nil
end

Instance Attribute Details

#async_deliveryObject

If true, enqueues the processing of a ‘Caffeinate::Mailing` to the background worker class as defined in `async_delivery_class`

Default is false



15
16
17
# File 'lib/caffeinate/configuration.rb', line 15

def async_delivery
  @async_delivery
end

#async_delivery_classObject

The background worker class for ‘async_delivery`.



18
19
20
# File 'lib/caffeinate/configuration.rb', line 18

def async_delivery_class
  @async_delivery_class
end

#batch_sizeObject

The number of ‘Caffeinate::Mailing` records we find in a batch at once.



24
25
26
# File 'lib/caffeinate/configuration.rb', line 24

def batch_size
  @batch_size
end

#default_ended_reasonObject

The default reason for an ended ‘Caffeinate::CampaignSubscription`



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

def default_ended_reason
  @default_ended_reason
end

#default_unsubscribe_reasonObject

The default reason for an unsubscribed ‘Caffeinate::CampaignSubscription`



37
38
39
# File 'lib/caffeinate/configuration.rb', line 37

def default_unsubscribe_reason
  @default_unsubscribe_reason
end

#deliver_laterObject

If true, uses ‘deliver_later` instead of `deliver`



21
22
23
# File 'lib/caffeinate/configuration.rb', line 21

def deliver_later
  @deliver_later
end

#drippers_pathObject

The path to the drippers



27
28
29
# File 'lib/caffeinate/configuration.rb', line 27

def drippers_path
  @drippers_path
end

#enabled_drippersObject

An array of Drippers that are enabled. Only used if you use Caffeinate.perform in your worker instead of calling separate drippers. If nil, will run all the campaigns.



41
42
43
# File 'lib/caffeinate/configuration.rb', line 41

def enabled_drippers
  @enabled_drippers
end

#implicit_campaignsObject

Automatically creates a ‘Caffeinate::Campaign` record by the named slug of the campaign from a dripper if none is found by the slug.



31
32
33
# File 'lib/caffeinate/configuration.rb', line 31

def implicit_campaigns
  @implicit_campaigns
end

#nowObject

Used for relation to a lot of things. If you have a weird time setup, set this. Accepts anything that responds to ‘#call`; you’ll probably use a block.



9
10
11
# File 'lib/caffeinate/configuration.rb', line 9

def now
  @now
end

Instance Method Details

#async_delivery?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/caffeinate/configuration.rb', line 70

def async_delivery?
  @async_delivery
end

#deliver_later?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/caffeinate/configuration.rb', line 74

def deliver_later?
  @deliver_later
end

#implicit_campaigns?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/caffeinate/configuration.rb', line 62

def implicit_campaigns?
  @implicit_campaigns
end

#time_nowObject



66
67
68
# File 'lib/caffeinate/configuration.rb', line 66

def time_now
  @now.call
end