Add deserialize_list helper

This commit is contained in:
Thor77 2018-11-25 20:08:55 +01:00
parent 4c05a7222e
commit 29b570bafa
No known key found for this signature in database
GPG Key ID: 5051E71B46AA669A
1 changed files with 6 additions and 0 deletions

View File

@ -4,4 +4,10 @@ module DeserializeHelpers
def deserialize_response(response)
ActiveModelSerializers::Deserialization.jsonapi_parse(JSON.parse(response.body))
end
def deserialize_list(response)
JSON.parse(response.body, symbolize_names: true)[:data].map do |raw_obj|
raw_obj[:attributes].merge raw_obj.except(:attributes)
end
end
end