Sha256: 59ea47a245c5d66642e7c65c65989f018569b31414daae092bdbc2b5f119253b

Contents?: true

Size: 385 Bytes

Versions: 2

Compression:

Stored size: 385 Bytes

Contents

module Mercy
  class Status
    attr_reader :reports

    def initialize(reports)
      @reports = reports
    end

    def status
      reports.any? { |r| r.error? } ? :error : :ok
    end

    def as_json
      {
        status: status
      }.merge(reports_jsons)
    end

    private

    def reports_jsons
      reports.map(&:as_json).as_hash(reports.map(&:id))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mercy-1.6.0 lib/mercy/status.rb
mercy-1.5.0 lib/mercy/status.rb