Skip to content

Instantly share code, notes, and snippets.

@davidpett
Created February 1, 2013 18:25
Show Gist options
  • Save davidpett/4693093 to your computer and use it in GitHub Desktop.
Save davidpett/4693093 to your computer and use it in GitHub Desktop.
DS.SCSerializer = DS.JSONSerializer.extend({
extractMany: function(loader, pre_json, type, records) {
var root = this.rootForType(type),
plural = this.pluralize(root),
json = {};
json[plural] = pre_json;
this.sideload(loader, type, json, plural);
this.extractMeta(loader, type, json);
if (json[plural]) {
var objects = json[plural], references = [];
if (records) { records = records.toArray(); }
for (var i = 0; i < objects.length; i++) {
if (records) { loader.updateId(records[i], objects[i]); }
var reference = this.extractRecordRepresentation(loader, type, objects[i]);
references.push(reference);
}
loader.populateArray(references);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment