Sha256: 8e380439d22b37e57a3fb484db39d1a5200eeeb368e67dffe46b62594014b60e

Contents?: true

Size: 463 Bytes

Versions: 5

Compression:

Stored size: 463 Bytes

Contents

module Grape
  module Batch
    # Format batch request response
    class Response
      def self.format(status, _headers, response)
        if response
          body = response.respond_to?(:body) ? response.body.join : response.join
          result = MultiJson.decode(body)
        end

        if (200..299).include?(status)
          { success: result }
        else
          { code: status, error: result['error'] }
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grape-batch-2.3.0 lib/grape/batch/response.rb
grape-batch-2.2.2 lib/grape/batch/response.rb
grape-batch-2.2.1 lib/grape/batch/response.rb
grape-batch-2.2.0 lib/grape/batch/response.rb
grape-batch-2.1.1 lib/grape/batch/response.rb