Sha256: 56c8da129d27c152868fb603dd37f91fbd0cc8cad1e91acb9c712243034e78fa

Contents?: true

Size: 744 Bytes

Versions: 1

Compression:

Stored size: 744 Bytes

Contents

module Esplanade
  class Response
    class Doc
      def initialize(request, raw)
        @request = request
        @raw = raw
      end

      def tomogram
        @tomogram ||= @request.doc.responses.find_all { |response| response['status'] == @raw.status }
        raise NotDocumented.new(**message) if @tomogram == []

        @tomogram
      end

      def json_schemas
        @json_schemas ||= tomogram.map { |action| action['body'] }
      end

      def status
        @status ||= tomogram['status']
      end

      private

      def message
        {
          request: {
            method: @request.raw.method,
            path: @request.raw.path
          },
          status: @raw.status
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
esplanade-1.5.0 lib/esplanade/response/doc.rb