coderly/ember-gdrive — pull request #19 by begedin (2014-12-13 21:10:24+00:00)
Title: Resolve issue with google drive realtime api entities containing read-only properties

# Issue

The way our ember-gdrive adapter now works is that it simply uses the object gapi returns to us, and it looks like some of that object's properties are now read only.

For a `hasMany` relationship, we overwrite the property containing a reference to a related item (for instance, widget property) with the actual value of the item. This is what throws an error.

# Solution (for now)

The (temporary) solution I've implemented is to execute `JSON.parse(JSON.stringify(entity))` on each entity retrieved from google's API. I've added a `clone` method to to adapter script and I'm calling it every time we're pushing an entity retrieved from `gapi` to the store. It's not ideal, but it allows me to continue work on Storypad until we figure out a proper solution.

I was hoping the adapter's `serialize` method would be the perfect hook to insert cloning into, but apparently, it's not. It simply isn't called at the proper time. Push is a store method, so I can't really write an override for that either: http://emberjs.com/api/data/classes/DS.Adapter.html#method_serialize

Perhaps adding a basic custom serializer would work?

There's also the question of a proper cloning method. JSON.parse(JSON.stringify(value)) works, but it's pretty much a hack. Any chance ember contains some helper clone method somewhere?