Created
September 23, 2008 17:20
-
-
Save erichocean/12350 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// This method is called by the various handlers once they have extracted | |
// their data. | |
refreshRecordsWithData: function(dataAry,recordType,cacheCode,loaded) { | |
var server = this ; | |
// first, prepare each data item in the Ary. | |
dataAry = dataAry.map(function(data) { | |
// camelize the keys received back. | |
data = server._camelizeData(data) ; | |
// convert the 'id' property to 'guid' | |
if (data.id) { data.guid = data.id; delete data.id; } | |
// find the recordType | |
if (data.type) { | |
var recordName = data.type.capitalize() ; | |
if (server.prefix) { | |
for (var prefixLoc = 0; prefixLoc < server.prefix.length; prefixLoc++) { | |
var prefixParts = server.prefix[prefixLoc].split('.'); | |
var namespace = window; | |
for (var prefixPartsLoc = 0; prefixPartsLoc < prefixParts.length; prefixPartsLoc++) { | |
var namespace = namespace[prefixParts[prefixPartsLoc]] ; | |
} | |
if (namespace != window) data.recordType = namespace[recordName] ; | |
if (data.recordType) break ; | |
} | |
} else data.recordType = window[recordName] ; | |
if (!data.recordType) console.log('skipping undefined recordType:'+recordName) ; | |
} else data.recordType = recordType ; | |
if (!data.recordType) return null; // could not process. | |
else return data ; | |
}).compact() ; | |
// now update. | |
SC.Store.updateRecords(dataAry,server,recordType,loaded) ; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment