Class: SinatraHealthCheck::Status::ForgivingAggregator

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra-health-check/status/forgiving_aggregator.rb

Overview

Aggregate sub statuus, best wins

Instance Method Summary collapse

Instance Method Details

#aggregate(statuus) ⇒ Object



3
4
5
6
7
8
# File 'lib/sinatra-health-check/status/forgiving_aggregator.rb', line 3

def aggregate(statuus)
  status = statuus.values.min_by { |s| s.to_i } || SinatraHealthCheck::Status.new(:ok, 'everything is fine')
  message = status.level == :ok ? 'everything is fine' : "all statuus are at least #{status.level}"

  SinatraHealthCheck::Status::Aggregated.new(status.level, message, statuus)
end