Class: Ni::Tools::Timers

Inherits:
Object
  • Object
show all
Defined in:
lib/ni/tools/timers.rb

Class Method Summary collapse

Class Method Details

.fetch_and_run(metadata_repository_klass, exceptions_logger = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ni/tools/timers.rb', line 3

def self.fetch_and_run(, exceptions_logger=nil)
  current_timers = .fetch_timers
  exceptions = []

  current_timers.each do |data|
    id, klass_name, action, system_uid = data

    begin
      klass_name.constantize.public_send(action, system_uid: system_uid)
    rescue Exception => e
      exceptions << e
    ensure
      .clear_timer!(id)
    end  
  end

  if exceptions_logger.present? && exceptions.present?
    exceptions.each { |e| exceptions_logger.log(e) }
  end  
end