Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Get converters and .attr working the right way with nested objects #264
The expected behavior of .attr when passed a nested object is as follows:
f9896d9 is where this went wrong. After fixing the logic, the question is what to do about this case:
The way its currently written, these owner attributes will be merged with what's currently in the owner observe. This means the actual data in the model store is overwritten, including the id and name.
In this case we need to know about the fact that owner is a model instance and not overwrite.
added a commit
Feb 2, 2013
The above commit gets all the issues Josh was trying to fix working, but avoids calling __convert too early. I'm unsure if this is the right way to fix the above issue:
My logic is if the curVal is a model and the new one looks like it should be data for this model, call _set to let the converter handle it. I could probably come up with some situations where this wouldn't work, like when there is some very weird custom converter that isn't .model or .models on this instance and they want the data to be merged into the existing model. Thoughts?