class Grape::Batch::Response

Format batch request response

Public Class Methods

format(status, _headers, response) click to toggle source
# File lib/grape/batch/response.rb, line 5
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