class HealthRack::Check

Attributes

duration[R]
title[R]
value[R]

Public Class Methods

new(title, &proc) click to toggle source
# File lib/health_rack/check.rb, line 7
def initialize(title, &proc)
  @title = title || raise(ArgumentError, "A title must be specified")
  @proc = proc || raise(ArgumentError, "A block must be specified")
end

Public Instance Methods

error?() click to toggle source
# File lib/health_rack/check.rb, line 26
def error?
  value.is_a? Exception
end
perform() click to toggle source
# File lib/health_rack/check.rb, line 12
def perform
  measure
  value
end
status() click to toggle source
# File lib/health_rack/check.rb, line 17
def status
  case value
  when nil, 0, false, Exception then false
  else true
  end
end
Also aliased as: status?
status?()
Alias for: status

Private Instance Methods

call() click to toggle source
# File lib/health_rack/check.rb, line 32
def call
  @value = begin
    @proc.call
  rescue Exception => ex
    # Need to log the exception
    ex
  end
end
measure() click to toggle source
# File lib/health_rack/check.rb, line 41
def measure
  @duration = Benchmark.realtime do
    call
  end
end