Class: Ops::Heartbeat

Inherits:
Object
  • Object
show all
Defined in:
lib/ops/heartbeat.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.add(name, &block) ⇒ Object



4
5
6
# File 'lib/ops/heartbeat.rb', line 4

def add(name, &block)
  instance.add name, &block
end

.check(name) ⇒ Object



8
9
10
# File 'lib/ops/heartbeat.rb', line 8

def check(name)
  instance.check(name)
end

.instanceObject



12
13
14
# File 'lib/ops/heartbeat.rb', line 12

def instance
  @instance ||= new
end

Instance Method Details

#add(name, &block) ⇒ Object



21
22
23
# File 'lib/ops/heartbeat.rb', line 21

def add(name, &block)
  heartbeats[name] = block
end

#check(name) ⇒ Object



25
26
27
28
29
30
# File 'lib/ops/heartbeat.rb', line 25

def check(name)
  heartbeats[name.to_sym].call
rescue StandardError => e
  puts "Error: #{e}\n#{e.backtrace[2..].join("\n")}" unless heartbeats[name.to_sym].nil?
  false
end

#heartbeatsObject



17
18
19
# File 'lib/ops/heartbeat.rb', line 17

def heartbeats
  @heartbeats ||= {}
end