Class: MailyHerald::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/maily_herald/manager.rb

Class Method Summary collapse

Class Method Details

.job_enqueued?Boolean

Check if Maily sidekiq job is running.

Returns:

  • (Boolean)


31
32
33
34
35
# File 'lib/maily_herald/manager.rb', line 31

def self.job_enqueued?
  Sidekiq::Queue.new.detect{|j| j.klass == "MailyHerald::Async" } || 
    Sidekiq::Workers.new.detect{|w, msg| msg["payload"]["class"] == "MailyHerald::Async" } ||
    Sidekiq::RetrySet.new.detect{|j| j.klass = "MailyHerald::Async" }
end

.run_allObject

Run all scheduled mailing deliveres.



23
24
25
26
27
28
# File 'lib/maily_herald/manager.rb', line 23

def self.run_all
  AdHocMailing.all.each {|m| m.run}
  OneTimeMailing.all.each {|m| m.run}
  PeriodicalMailing.all.each {|m| m.run}
  Sequence.all.each {|m| m.run}
end

.run_mailing(mailing) ⇒ Object

Run scheduled periodical mailing deliveres.

Parameters:



16
17
18
19
20
# File 'lib/maily_herald/manager.rb', line 16

def self.run_mailing mailing
  mailing = Mailing.find_by_name(mailing) unless mailing.is_a?(Mailing)

  mailing.run if mailing
end

.run_sequence(sequence) ⇒ Object

Run scheduled sequence mailing deliveries.

Parameters:



6
7
8
9
10
# File 'lib/maily_herald/manager.rb', line 6

def self.run_sequence sequence
  seqence = Sequence.find_by_name(seqence) unless seqence.is_a?(Sequence)

  sequence.run if sequence
end