blueprinter
blueprinter copied to clipboard
Out of date documentation
The documentation for .association, more specifically it's options parameter, says:
:blueprint (Symbol) — Required. Use this to specify the blueprint to use for the associated object.
I think it's missing the fact that one can pass a lambda to dynamically evaluate the blueprint to use.
Link to the doc: https://www.rubydoc.info/gems/blueprinter/Blueprinter/Base#association-class_method
I was lucky to look at old issues, and see that a PR had been merged for this feature that I needed.
Let me know if I missed something.
Thank you for bringing this to our attention, Robin. We do mention this in the Defining An Association Directly In The Blueprint section, but could probably stand to clarify by moving it all under the same section.
You do indeed, in Supporting Dynamic Blueprints For Associations! I missed that. I focused on the doc only.
No problem -- We could stand to clarify this a bit more. Thanks for contributing!
Good callout, we'll update that portion of the documentation and leave this issue open until that's resolved. Thanks!
If I could piggy back on this issue, the render_as_hash documentation section says its the same as render which implies that its an alias but they return different things. Maybe some clarification or just remove the "Same as render" part or reword it differently. This also goes for the render_as_json documentation.
Speaking of the render method, do you think that maybe it would be better to have something like:
# Could name the option 'adapter' or 'style', something to that effect.
PostBluePrinter.render(post, adapter: :json)
PostBluePrinter.render(post, style: :hash)
Adding it as an option instead of creating three different render methods seems more "coding best practice" to me. If this is something even worth considering, let me know and I'll create a new issue for this and even try to do a PR for it as this is a "found a problem, create the solution" kind of thing.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.