json-api-vanilla
json-api-vanilla copied to clipboard
Normalize hash before parse the objects
Hi guys. The example for building method is not working properly, it's build Document with nils
see example bellow or test case in branch:
[1] pry(main)>
[2] pry(main)>
[3] pry(main)> hash = {
[3] pry(main)* data: [
[3] pry(main)* {
[3] pry(main)* id: 'a123',
[3] pry(main)* type: 'user',
[3] pry(main)* attributes: {
[3] pry(main)* activated_at: '2020-06-11'
[3] pry(main)* }
[3] pry(main)* }
[3] pry(main)* ]
[3] pry(main)* }
=> {:data=>[{:id=>"a123", :type=>"user", :attributes=>{:activated_at=>"2020-06-11"}}]}
[4] pry(main)> JSON::Api::Vanilla.build(hash)
=> #<JSON::Api::Vanilla::Document:0x00007f97e2adaaf8
@container=#<Module:0x00007f97e2adae68>,
@data=nil,
@errors=nil,
@keys={},
@links={nil=>nil},
@meta={nil=>nil},
@objects={},
@rel_links={},
@superclass=#<Class:0x00007f97e2adadf0>>