module Rack::Cargo::BatchResponse

Public Class Methods

from_result(result) click to toggle source
# File lib/rack/cargo/batch_response.rb, line 7
def from_result(result)
  if result[:success]
    respond_with(200, result[:responses])
  else
    respond_with(422, errors: result[:errors])
  end
end

Private Class Methods

respond_with(status, body) click to toggle source
# File lib/rack/cargo/batch_response.rb, line 17
def respond_with(status, body)
  response_headers = { "Content-Type" => "application/json" }
  [status, response_headers, [body.to_json]]
end