active_model_serializers
active_model_serializers copied to clipboard
Add ancestors accessor to nested serializer
Feature Request
TL;DR: add ancestors
method to a serialize instance
In the same way that it is possible to access scope
and object
inside a serializer instance, we'd also like to access its parent
and so on... Maybe an ancestors
method that makes it possible to access the "ancestors" of a nested serializer instance.
The use case for this feature came from an authorization implementation of ours, where a nested serializer object needs to know about its ancestors in order to decide if a given field should be serialized or not, or even even such field should be serialized with an anonymized value.
We actually added this behaviour already at our own fork, and I'd like to know if this is a feature that could be worth of a PR around here (we are using 0-10-stable
).
would be awesome to see a PR covering tests (some doc would be nice to see too), which would help us to understand the feature request more clearly. thanks