Open danielnc opened 3 years ago
@danielnc Thanks for reporting this issue!
I see what you say and totally agree, this happens because aliases works on attributes and not on methods. Since serializer is not strict to specific model (as of today), I can't know if "friendly_state" is a method on a model and then alias to it's method.
Making serializers strongly typed, is something I want to achieve in the future but not now.
I'll try to think about an options how to solve this without complicating the library.
If you want to submit PR and need help with it, I'll be gladly guide you (you can join the Slack group)
I have a AR model that has a db column called state, and I want to transform it before serializing the data. That method that transforms data lives on the AR model
When delegating the method to the AR object + aliasing it, panko is not working the way I would expect. it's returning the actual persisted database value for object#state
I can accomplish what I want by doing but I think it would be a better approach to be able to rely on aliases + method delegation