This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: function() { | |
var records = Ember.RecordArray.create({ | |
modelClass: this, | |
content: [] | |
}); | |
var cache = this.recordCache; | |
if (!cache) { return records; } | |
Object.keys(cache).forEach(function(id) { | |
records.addObject(cache[id]); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
didCreateRecord: function(record, data) { | |
var rootKey = get(record.constructor, 'rootKey'), | |
primaryKey = get(record.constructor, 'primaryKey'), | |
dataToLoad = rootKey ? data[rootKey] : data; | |
record.set(primaryKey, dataToLoad[primaryKey]); // setting the id returned by the server | |
record.load(dataToLoad[primaryKey], dataToLoad); | |
record.didCreateRecord(); | |
}, |