-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add options to transform field keys non-recursively (#132) #310
Add options to transform field keys non-recursively (#132) #310
Conversation
I'm not opposed to the current naming, but since you are interested in alternative ideas: "shallow" is an alright word for what you're doing here. |
This seems like a good direction to go in. I'll do a more in-depth look at your implementation of |
eb0593d
to
fae926b
Compare
Ok, I've updated the config values to |
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.
This feels a bit pedantic, but I noticed that expand_fields/2
handles all sorts of data types whereas expand_fields_once/2
only handles maps. On one hand, it only needs to in order to handle the job of transforming only the names of attributes of the map within JSON:API data
. On the other hand, it's a utility function with theoretically broader usage that doesn't do the same thing as expand_fields/2
but only once as its name suggests.
Any other ideas what to call it? Off the cuff I'd say expand_map_fields_once/2
but I'm not tied to that name.
Aside from that small detail, this looks good!
Totally. What do you think of |
|
|
fae926b
to
dcbf608
Compare
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.
This looks great. Thank you!
I'll cut a new release shortly. #311 |
Following up on this discussion.
This adds two new values for the config option
transform_fields
:camelize_shallow
: Likecamelize
, but only affects the relationship and attribute keys, not their values.dasherize_shallow
: Likedasherize
, but only affects the relationship and attribute keys, not their values.Some users may have views with fields that are maps, and don't want the map's keys dasherized or camelized. The new config values allow these users to use the
transform_fields
option to transform only the field names, but not the values.Feedback is requested. I don't really like the config value names—preferably we can think of something better. If this seems like the right direction, I'll continue to update the documentation.