You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You could implement a decorator/presenter pattern, which is responsible for memoizing and used as model of the serializer. With that you keep your model clean and independent of jsonapi.
Indeed that is exactly what my code does there. The presenter class is called Presenter.
Oh sorry, I overlooked that. I had an experience with another json-api-serializing-gem with the same problem. In the meantime I don't see it as a disadvantage to implement presenters between the models and the view-serializers.
Activity
Startouf commentedon Dec 12, 2019
Hey, any news on this ? What's the recommended way to perform memoisation in serializers ?
Right now our solution is to memoize on the model but this feels dirty.
ClayShentrup commentedon Jun 20, 2020
Yeah this is frustrating. I just do a presenter.
wuarmin commentedon Jun 21, 2020
You could implement a decorator/presenter pattern, which is responsible for memoizing and used as model of the serializer. With that you keep your model clean and independent of jsonapi.
ClayShentrup commentedon Jun 21, 2020
Indeed that is exactly what my code does there. The presenter class is called Presenter.
wuarmin commentedon Jun 23, 2020
Oh sorry, I overlooked that. I had an experience with another json-api-serializing-gem with the same problem. In the meantime I don't see it as a disadvantage to implement presenters between the models and the view-serializers.