-
Notifications
You must be signed in to change notification settings - Fork 148
Open
Milestone
Description
Expected Behaviour
I need to include/exclude data for relationships depending on external parameter given to serializer.
For example BundleSerializer.new(bundle, params: { lazy_load_instruments_data: true }) should exclude the data for relationships.
And BundleSerializer.new(bundle, params: { lazy_load_instruments_data: false }) should include the data
It could be resolved by passing the proc as an argument to lazy_load_data
has_many :instruments, lazy_load_data: Proc.new { |_, params| params[:lazy_load_instruments_data] == true }, links: {
related: -> (object) {
url_helpers.instruments_url(related_id: object.id)
}
}
Actual Behaviour
Even if we pass a proc as in example above it always count the lazy_load_data as true because:
output_hash[key][:data] = ids_hash_from_record_and_relationship(record, serialization_params) || empty_case unless lazy_load_data && !included
Steps to Reproduce the Problem
- Pass conditional Proc as value of
lazy_load_data - It always count
lazy_load_data: trueeven if Proc returns false
Specifications
- Version: 2.1.0
- Ruby version: 2.7.1p83
It's not a bug but the feature request, I can add it just want to check if we are ok with this behaviour
kln
Metadata
Metadata
Assignees
Labels
No labels