class Boppers::Runner

Public Instance Methods

boppers() click to toggle source
# File lib/boppers/runner.rb, line 5
def boppers
  Boppers.configuration.boppers
end
call() click to toggle source
# File lib/boppers/runner.rb, line 29
def call
  threads = boppers.each_with_object([]) do |bopper, buffer|
    buffer << run_bopper(bopper)
  end

  threads.each(&:join)
end
run_bopper(bopper) click to toggle source
# File lib/boppers/runner.rb, line 9
def run_bopper(bopper)
  interval = if bopper.respond_to?(:interval)
               bopper.interval
             else
               60
             end

  Thread.new do
    loop do
      begin
        bopper.call
      rescue StandardError => error
        Boppers.configuration.handle_exception&.call(error)
      end

      sleep interval
    end
  end
end