Re:Show HN: Shale – a Ruby object mapper and serializer for ...
by halostatue on Tuesday May 31, 2022 @12:17PM
(#31571371)
I haven’t looked at the Shale source code, but I suspect that it would not be hard to add `mapped_class` support the way you’ve described it, so that the business objects are not themselves mapper instances. At a guess, the `from_xml` probably does something like (vastly over simplified):
It would then be possible to change this to:
This would make it easier to solve a larger problem of needing to serialize the same business object in different ways for different consumers with different levels of detail. It would also permit the construction of mappers for temporary objects that contain the details for more complex serializations that have indirect connections.
[ Parent
| on HN ]
There are no comments on this comment yet.