Class: SinatraHealthCheck::Status::OverwritingAggregator

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

Overview

Aggregate statuus with an aggregator but allow overwriting :level and :message.

Instance Method Summary collapse

Constructor Details

#initialize(aggregator) ⇒ OverwritingAggregator

Returns a new instance of OverwritingAggregator.

Raises:

  • (ArgumentError)


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

def initialize(aggregator)
  raise ArgumentError, 'aggregator must respond to .aggregate' unless aggregator.respond_to?(:aggregate)
  @aggregator = aggregator
end

Instance Method Details

#aggregate(statuus, overwrite = nil) ⇒ Object

aggregate statuus with given aggregator, but overwrite :status and :message if overwrite is given too



9
10
11
12
13
14
15
# File 'lib/sinatra-health-check/status/overwriting_aggregator.rb', line 9

def aggregate(statuus, overwrite = nil)
  if overwrite
    SinatraHealthCheck::Status::Aggregated.new(overwrite.level, overwrite.message, statuus)
  else
    @aggregator.aggregate(statuus)
  end
end