Module: JSONAPI::Serialization::IncludeFiltering
- Included in:
- IncludesSerialization
- Defined in:
- lib/json_api/serialization/concerns/include_filtering.rb
Instance Method Summary collapse
-
#filter_loaded_records(association, related_klass) ⇒ Object
When the authorization_scope hook or the resource's records scope narrows the relation, the eager-loaded set — preloaded through acts_as_tenant alone — must be re-checked against the narrowed scope, so a relationship never surfaces a record the related endpoint denies.
Instance Method Details
#filter_loaded_records(association, related_klass) ⇒ Object
When the authorization_scope hook or the resource's records scope narrows the relation, the eager-loaded set — preloaded through acts_as_tenant alone — must be re-checked against the narrowed scope, so a relationship never surfaces a record the related endpoint denies. The request-scoped cache memoizes the scopes and the per-id verdicts, so each record is vetted at most once per request.
12 13 14 15 16 17 |
# File 'lib/json_api/serialization/concerns/include_filtering.rb', line 12 def filter_loaded_records(association, ) loaded_array = association.target.respond_to?(:to_a) ? association.target.to_a : Array(association.target) return [] if loaded_array.empty? include_filter_cache.filter(loaded_array, ) end |