Module: Caffeinate::Dripper::Perform

Defined in:
lib/caffeinate/dripper/perform.rb

Overview

Handles delivering a ‘Caffeinate::Mailing` for the `Caffeinate::Dripper`.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

:nodoc:



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

def self.included(klass)
  klass.extend ClassMethods
end

Instance Method Details

#perform!Object

Delivers the next_caffeinate_mailer for the campaign’s subscribers. Handles with batches based on ‘batch_size`.

OrderDripper.new.perform!

Returns:

  • nil



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/caffeinate/dripper/perform.rb', line 17

def perform!
  run_callbacks(:before_perform, self)
  self.class.upcoming_mailings
    .in_batches(of: self.class.batch_size)
    .each do |batch|
    run_callbacks(:on_perform, self, batch)
    batch.each(&:process!)
  end
  run_callbacks(:after_perform, self)
  nil
end