Class: SinatraHealthCheck::Status::Aggregated

Inherits:
SinatraHealthCheck::Status show all
Defined in:
lib/sinatra-health-check/status/aggregated.rb

Overview

Application status definition with subsystems

Constant Summary

Constants inherited from SinatraHealthCheck::Status

SEVERITIES

Instance Attribute Summary collapse

Attributes inherited from SinatraHealthCheck::Status

#extras, #level, #message

Instance Method Summary collapse

Methods inherited from SinatraHealthCheck::Status

#to_i, #to_json

Constructor Details

#initialize(level, message, statuus, extras = {}) ⇒ Aggregated

Returns a new instance of Aggregated.

Raises:

  • (ArgumentError)


6
7
8
9
10
# File 'lib/sinatra-health-check/status/aggregated.rb', line 6

def initialize(level, message, statuus, extras = {})
  raise ArgumentError, "statuus must be a hash of SinatraHealthCheck::Status, but is #{statuus.class}" \
    unless statuus.is_a?(Hash)
  super(level, message, { :statusDetails => statuus }.merge(extras))
end

Instance Attribute Details

#statuusObject (readonly)

Returns the value of attribute statuus.



4
5
6
# File 'lib/sinatra-health-check/status/aggregated.rb', line 4

def statuus
  @statuus
end

Instance Method Details

#to_hObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/sinatra-health-check/status/aggregated.rb', line 12

def to_h
  subs = {}
  extras[:statusDetails].each { |k,v| subs[k] = v.to_h }

  s = extras.merge({
    :status  => level.to_s.upcase,
    :message => message,
    :statusDetails => subs
  })
  s.delete(:statusDetails) if s[:statusDetails].size == 0
  s
end