You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe
I can't pass a Enumerator::Lazy as a blueprinter association.
Describe the feature you'd like to see implemented
I guess there are a lot of ways to solve this:
Option 1) Blueprinter handles this "forcefully" -- just call .force to load the enumerable.
Option 2) Blueprinter handles this more gracefully, using one of the "consumption" methods, only loading the data when it's actually being used
Option 3) Blueprinter doesn't handle this -- user has to pass loaded data, or hook into pre_render and do it there, or something like that.
IMO it would be pretty cool if there was a graceful handling of this data. Don't know how that fits into the, sort of, engineering principles of blueprinter as a whole, but if something like this does make sense I might be able to help contribute.
(I have a working version that just forces the data to load here)
Describe alternatives you've considered
Like I listed above, I could just call .force
association(:my_association,blueprint: MyAssociatedBlueprint,view: :normal)do |association,opts|
opts[:cached_thing].force# force lazy enumerable to evaluateend
but that doesn't feel very good.
Additional context
No response
The text was updated successfully, but these errors were encountered:
Thanks for bringing this up @nickagliano-st (and apologies for the delayed response)!
We've been taking more of an intentional stance that the scope of responsibil
659E
ity of blueprinter should begin and end with serialization of data, and shouldn't extend into needing to understand how that data was (or should be) aggregated. This is primarily to prevent blueprinter from becoming too coupled to any particular data persistence implementation (e.g. ActiveRecord, rom-rb, etc.).
However, since this is more of a native Ruby concern, I think it'd be reasonable for the library to handle this situation implicitly.
As far as implementation goes, we'd like to move away from the current array_like? implementation in an upcoming iteration, so while having an additional lazy_array_like? check would be the most tractable approach currently, we may want to reassess if there's a way we'd like to implement this longer term.
In the meantime, though, feel free to open a PR to add this behavior, and we can continue the discussion there!
Is there an existing issue for this?
Is your feature request related to a problem? Please describe
I can't pass a
Enumerator::Lazy
as a blueprinter association.Describe the feature you'd like to see implemented
I guess there are a lot of ways to solve this:
Option 1) Blueprinter handles this "forcefully" -- just call
.force
to load the enumerable.Option 2) Blueprinter handles this more gracefully, using one of the "consumption" methods, only loading the data when it's actually being used
Option 3) Blueprinter doesn't handle this -- user has to pass loaded data, or hook into pre_render and do it there, or something like that.
IMO it would be pretty cool if there was a graceful handling of this data. Don't know how that fits into the, sort of, engineering principles of blueprinter as a whole, but if something like this does make sense I might be able to help contribute.
(I have a working version that just forces the data to load here)
Describe alternatives you've considered
Like I listed above, I could just call
.force
but that doesn't feel very good.
Additional context
No response
The text was updated successfully, but these errors were encountered: