Closed beauby closed 7 years ago
@@ master #7 diff @@
===================================
Files 5 5
Lines 146 157 +11
Methods 0 0
Messages 0 0
Branches 0 0
===================================
+ Hits 146 157 +11
Misses 0 0
Partials 0 0
Powered by Codecov. Last update 707a20a...aad510d
Closed by #10.
TL;DR
Deserialization now deserializes the whole payload (no more whitelisting), with the ability to add custom mappings for specific attributes/relationships (and type/id).
Longer explanation
This PR changes the way deserialization works. Current situation is: we loop through the explicitly targeted elements (id/type/attributes/relationships), and for each element, if it is present in the payload, we create the corresponding fields.
With this PR, we do the opposite: we loop through the elements of the payload, and for each of those, if there is a custom block, we use it, otherwise we fall back to a default deserialization scheme (depending on whether it is the type/id, an attribute, a has_one relationship, or a has_many relationship).
This "default deserialization scheme for (type|id|attributes|has_one relationships|has_many relationships)" is overridable by overriding the
deserialize_attribute(key, value)
,deserialize_has_one(key, value, id, type)
, anddeserialize_has_many(key, value, ids, types)
methods.Closes #5 as this removes whitelisting.