Setting the readable option on a relationship to a callables (procs, lambdas, etc) would only evaulate on load (once). Conditionally hiding relationships per request was not supported. Feature was disabled
Current State (before PR)
readable option on relationships (has_many, belongs_to) doesn't support callables (procs, lambdas, etc).
This PR
Adds support for setting readable with callables.
Changes
Sideload evaluates readable flag every time so that the read conditions can be check against current request (or context)
Move readable check to serializer. Sets :if option on JSONAPI::Serializable::Relationship object with lambda that calls sideload.readable?
Apply sideload/relationship without checking readable? on sideload since the check will be happening in the serializer.
Filters out the include from the include_hash if the current included relationships is not readable.
History
Setting the
readable
option on a relationship to a callables (procs, lambdas, etc) would only evaulate on load (once). Conditionally hiding relationships per request was not supported. Feature was disabledCurrent State (before PR)
readable
option on relationships (has_many
,belongs_to
) doesn't support callables (procs, lambdas, etc).This PR
Adds support for setting
readable
with callables.Changes
Sideload
evaluates readable flag every time so that the read conditions can be check against current request (or context):if
option onJSONAPI::Serializable::Relationship
object with lambda that callssideload.readable?
readable?
on sideload since the check will be happening in the serializer.include_hash
if the current included relationships is not readable.