-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.0 Base Class Proposal #437
Conversation
d9a4438
to
d4100bf
Compare
Alt view options: WidgetBlueprint.render(obj, view: "extended.plus")
WidgetBlueprint["extended.plus"].render(obj) |
6dd4924
to
1b9c837
Compare
ca8abf8
to
975c735
Compare
Signed-off-by: Jordan Hollinger <[email protected]>
…lias to self Signed-off-by: Jordan Hollinger <[email protected]>
Signed-off-by: Jordan Hollinger <[email protected]>
51781e8
to
7af7bae
Compare
6ad1a78
to
ef93e6f
Compare
ef93e6f
to
e0ba891
Compare
Signed-off-by: Jordan Hollinger <[email protected]>
… matter Signed-off-by: Jordan Hollinger <[email protected]>
e0ba891
to
a29cf5c
Compare
What about extractor classes that could be provided to fields and associations? Is that something that is addressed in this PR? blueprinter/lib/blueprinter/field.rb Line 11 in b90d251
We are currently using custom extractors to cache the values of extracted fields, and to detect infinite recursion while extracting a field (field references itself). See the related issue about extractor configurability. |
We're still looking at how we want to implement extractors, and a few other things, in V2. Those will be follow-up PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan on giving this another thorough review, but I'm inclined to suggest that we try breaking this apart, and introduce each component separately, as there's a lot of new concepts at play here. I know we're merging into a release branch, but I believe it'd make it easier to break down iterate on moving forward.
lib/blueprinter/v2.rb
Outdated
|
||
module Blueprinter | ||
# Base class for V2 Blueprints | ||
class V2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading through this again with fresh eyes, I'm less inclined to want to codify the version as part of the class itself, especially since it doesn't quite describe what the class is as much.
The versioning system we were originally going with does seem over-engineered based on our current expectations, but I'm curious if we could have a more expressive name, and then introduce those versioning semantics later on if needed (e.g. class Blueprint
-> Blueprint[3.0]
).
Otherwise, I'd lean more towards BlueprintV2
if we want to stick with the explicit version in the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made V2
a module and moved this code to V2::Base
for now.
lib/blueprinter/v2.rb
Outdated
self.partials = {} | ||
self.used_partials = [] | ||
self.extensions = [] | ||
self.options = Options.new(DEFAULT_OPTIONS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nb: I'd expect DEFAULT_OPTIONS
to be encapsulated solely within Options
, and that simply calling Options.new
would initialize it with the defaults.
Signed-off-by: Jordan Hollinger <[email protected]>
98d07ac
to
f7beaa0
Compare
For posterity (as discussed in the meeting): In my mind, the important part of this PR is the view/class inheritance structure and associated DSL. That is: how fields, associations, partials, options, and extensions are inherited from a parent class/view into child classes/views in a consistent, predictable manner, obviating the need for global config and unifying the "blueprint" and "view" concepts. The included implementations of |
Signed-off-by: Jordan Hollinger <[email protected]>
16de5f5
to
b6d7495
Compare
Signed-off-by: Jordan Hollinger <[email protected]>
b6d7495
to
749b596
Compare
Signed-off-by: Jordan Hollinger <[email protected]>
Signed-off-by: Jordan Hollinger <[email protected]>
Signed-off-by: Jordan Hollinger <[email protected]>
Signed-off-by: Jordan Hollinger <[email protected]>
Signed-off-by: Jordan Hollinger <[email protected]>
Signed-off-by: Jordan Hollinger <[email protected]>
035dfe8
to
af1bc20
Compare
A proposed V2 base class.
Overview
:default
view is just an alias toself
(i.e. the Blueprint class).object
= singular association,collection
= multiple (names up for debate)Notes
MyBlueprint < Blueprinter[2.0]
syntax in this PR, but we can add it later if we want.Defining
Rendering
Reflection