Sha256: 804c340a5cd6aafc0369eafc36579375bd33a95a375f9a275d884ed5a05f641a

Contents?: true

Size: 441 Bytes

Versions: 2

Compression:

Stored size: 441 Bytes

Contents

module Bidu
  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
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
mercy-1.3.0 lib/bidu/mercy/status.rb
bidu-mercy-1.3.0 lib/bidu/mercy/status.rb