AmpersandJS / ampersand-model

Observable objects, for managing state in applications.
MIT License
84 stars 31 forks source link

Save with `wait:true`, `patch: true` and custom `serialize()` method #64

Open bobholt opened 8 years ago

bobholt commented 8 years ago

fixes #52

When calling the save() method with wait: true and patch: true, the current implmentation assumes a basic data structure and ignored the structure generated by an overridden serialize method.

This fix invokes the serialize() method to ensure the user's data structure is respected. In order for this to work with PATCH, we have to inspect that structure to find where the attributes have been placed, and then limit the properties of those object to only the ones changed.

This still makes some assumptions about the data structure (namely that all attributes appear within a single object within the serialized structure), but hopefully less restrictive ones than the current implementation.

bobholt commented 8 years ago

Thanks for the feedback @wraithgar. Additional commits to address those issues.

wraithgar commented 8 years ago

I think I've asked all the questions I had when looking at this PR. Would love more eyeballs on this.

bobholt commented 8 years ago

I've found some issues with this in production. I should be close to resolving, then will update this PR.