-
Notifications
You must be signed in to change notification settings - Fork 63
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
Simplify jsonapi_class configuration #92
base: master
Are you sure you want to change the base?
Simplify jsonapi_class configuration #92
Conversation
d605448
to
b05a5e5
Compare
Adds • JSONAPI::Rails::SerializableClassMapping class Overriding Hash’s lookup can be confusing without creating an descendent class. - Old behavior inferrer.class == Hash Doesn’t make it obvious that there’s custom behavior - New behavior inferrer.class == JSONAPI::Rails::SerializableClassMapping Now it’s obvious where to look for the unusual behavior This setup also allows us to define the default mappings and the lookup behavior in separate configuration options • configuration options for 1. jsonapi_class_mapper 2. jsonapi_class_mappings 3. jsonapi_errors_class_mapper (fallback to jsonapi_class_mapper if nil) 4. jsonapi_errors_class_mappings Removes • configration options for 1. jsonapi_class 2. jsonapi_errors_class
b05a5e5
to
975793f
Compare
Looks like this PR would benefit this issue too #68 |
a01e8f0
to
8b885e0
Compare
8b885e0
to
0d1cddf
Compare
…ized Render error when unable to deserialize resource
This looks good to me, and solves some confusion I'm seeing on my project. Any chance we can move it forward? |
hi @JoeWoodward. Yeah, I'm maintaining, but at the moment I have some health problems, I'll have more time in few weeks. According to your PR:
Contributions are welcomed |
@JoeWoodward Yes, I haven't had time to give the love this project deserves, and @dawidof is in charge now. This PR does several things (update TravisCI configuration, jsonapi payload for invalid request, and change of the lookup mechanism) – would you mind splitting it up into semantic chunks? Regarding splitting the lookup in two parts, one for static mapping, and one for dynamic mapping, I do not see the value, as it makes the code more complex. The current behavior, where the inferrer is a |
Hey, @dawidof, @beauby! Thanks for the responses, been so long I almost forgot I wrote these PRs Just had to read my code again for a while to remember the issues I was experiencing. The reason I made a custom class that inherited from Hash to do the mapping was due to wasting a lot of time trying to figure out how the mappings worked when I was build a project last year...
It's not often that you see Hash objects that do not follow the standard behavior of a Hash so it's easy to forget that it's even possible to modify the lookup logic, trying to debug that was really confusing. I believe it took me over a day to find the config that showed the Hash documentation; by changing the class name you make it really obvious where too look. Now when you call Regarding splitting the dynamic/static values up and modifying the Hash lookup behavior in the Thanks for the feedback, I will try to find some time to split this PR up. |
Also, sorry to hear about your health problems @dawidof, hope you're recover{ed,ing} now. |
Adds
• JSONAPI::Rails::SerializableClassMapping class
Overriding Hash’s lookup can be confusing without creating an
descendent class.
inferrer.class == Hash
Doesn’t make it obvious that there’s custom behavior
inferrer.class == JSONAPI::Rails::SerializableClassMapping
Now it’s obvious where to look for the unusual behavior
This setup also allows us to define the default mappings and the
lookup behavior in separate configuration options
• configuration options for
(fallback to jsonapi_class_mapper if nil)
Removes
• configration options for