Class: Caffeinate::Drip

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

Overview

A Drip object

Handles the block and provides convenience methods for the drip

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dripper, action, options, &block) ⇒ Drip

Returns a new instance of Drip.



10
11
12
13
14
15
# File 'lib/caffeinate/drip.rb', line 10

def initialize(dripper, action, options, &block)
  @dripper = dripper
  @action = action
  @options = options
  @block = block
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



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

def action
  @action
end

#blockObject (readonly)

Returns the value of attribute block.



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

def block
  @block
end

#dripperObject (readonly)

Returns the value of attribute dripper.



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

def dripper
  @dripper
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#enabled?(mailing) ⇒ Boolean

Checks if the drip is enabled

Returns:

  • (Boolean)


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

def enabled?(mailing)
  DripEvaluator.new(mailing).call(&@block)
end

#parameterized?Boolean

If the associated ActionMailer uses ‘ActionMailer::Parameterized` initialization instead of argument-based initialization

Returns:

  • (Boolean)


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

def parameterized?
  options[:using] == :parameterized
end

#send_atObject



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

def send_at
  options[:delay].from_now
end