Class: HealthRack::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/health_rack/check.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, &proc) ⇒ Check

Returns a new instance of Check.



7
8
9
10
# 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

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



5
6
7
# File 'lib/health_rack/check.rb', line 5

def duration
  @duration
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/health_rack/check.rb', line 5

def title
  @title
end

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/health_rack/check.rb', line 5

def value
  @value
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/health_rack/check.rb', line 26

def error?
  value.is_a? Exception
end

#performObject



12
13
14
15
# File 'lib/health_rack/check.rb', line 12

def perform
  measure
  value
end

#statusObject Also known as: status?



17
18
19
20
21
22
# File 'lib/health_rack/check.rb', line 17

def status
  case value
  when nil, 0, false, Exception then false
  else true
  end
end