File tree Expand file tree Collapse file tree 2 files changed +30
-38
lines changed
Expand file tree Collapse file tree 2 files changed +30
-38
lines changed Original file line number Diff line number Diff line change @@ -94,8 +94,8 @@ defmodule JSONAPI.Utils.DataToParams do
9494
9595 defp process_included ( % { "included" => included } = incoming ) do
9696 included
97- |> Enum . reduce ( incoming , fn % { "data" => % { " type" => type } } = params , acc ->
98- flattened = process ( params )
97+ |> Enum . reduce ( incoming , fn % { "type" => type } = params , acc ->
98+ flattened = process ( % { "data" => params } )
9999
100100 case Map . has_key? ( acc , type ) do
101101 false -> Map . put ( acc , type , [ flattened ] )
Original file line number Diff line number Diff line change @@ -106,13 +106,11 @@ defmodule JSONAPI.DataToParamsTest do
106106 } ,
107107 "included" => [
108108 % {
109- "data" => % {
110- "attributes" => % {
111- "name" => "Tara"
112- } ,
113- "id" => "234" ,
114- "type" => "friend"
115- }
109+ "attributes" => % {
110+ "name" => "Tara"
111+ } ,
112+ "id" => "234" ,
113+ "type" => "friend"
116114 }
117115 ]
118116 }
@@ -144,42 +142,36 @@ defmodule JSONAPI.DataToParamsTest do
144142 } ,
145143 "included" => [
146144 % {
147- "data" => % {
148- "id" => "234" ,
149- "type" => "friend" ,
150- "attributes" => % {
151- "name" => "Tara"
152- } ,
153- "relationships" => % {
154- "baz" => % {
155- "data" => % {
156- "id" => "2" ,
157- "type" => "baz"
158- }
159- } ,
160- "boo" => % {
161- "data" => nil
145+ "id" => "234" ,
146+ "type" => "friend" ,
147+ "attributes" => % {
148+ "name" => "Tara"
149+ } ,
150+ "relationships" => % {
151+ "baz" => % {
152+ "data" => % {
153+ "id" => "2" ,
154+ "type" => "baz"
162155 }
156+ } ,
157+ "boo" => % {
158+ "data" => nil
163159 }
164160 }
165161 } ,
166162 % {
167- "data" => % {
168- "attributes" => % {
169- "name" => "Wild Bill"
170- } ,
171- "id" => "0012" ,
172- "type" => "friend"
173- }
163+ "attributes" => % {
164+ "name" => "Wild Bill"
165+ } ,
166+ "id" => "0012" ,
167+ "type" => "friend"
174168 } ,
175169 % {
176- "data" => % {
177- "attributes" => % {
178- "title" => "Sr"
179- } ,
180- "id" => "456" ,
181- "type" => "organization"
182- }
170+ "attributes" => % {
171+ "title" => "Sr"
172+ } ,
173+ "id" => "456" ,
174+ "type" => "organization"
183175 }
184176 ]
185177 }
You can’t perform that action at this time.
0 commit comments