lib/ecoportal/api/common/batch_operation.rb in ecoportal-api-0.3.3 vs lib/ecoportal/api/common/batch_operation.rb in ecoportal-api-0.3.4
- old
+ new
@@ -18,27 +18,25 @@
end
}
end
def process_response(response)
- if response.success?
- response.body.each.with_index do |subresponse, idx|
- next unless callback = @operations[idx][:callback]
+ raise "Total failure in batch operation" unless response.success?
- status = subresponse["status"]
- body = subresponse["response"]
- method = @operations[idx][:method]
+ response.body.each.with_index do |subresponse, idx|
+ next unless callback = @operations[idx][:callback]
- if status == 200 && method == "GET"
- batch_response = BatchResponse.new(status, body, @wrapper.new(body))
- callback.call batch_response, batch_response.result
- else
- batch_response = BatchResponse.new(status, body)
- callback.call batch_response
- end
+ status = subresponse["status"]
+ body = subresponse["response"]
+ method = @operations[idx][:method]
+
+ if status == 200 && method == "GET"
+ batch_response = BatchResponse.new(status, body, @wrapper.new(body))
+ callback.call batch_response, batch_response.result
+ else
+ batch_response = BatchResponse.new(status, body)
+ callback.call batch_response
end
- else
- raise "Total failure in batch operation"
end
end
def get(doc)
id = get_id(doc)