Add resetData, unload and removeFromCache to Travis.Model

This commit is contained in:
Piotr Sarnacki 2013-07-31 13:56:19 +02:00
parent 647863ca59
commit 549efc8046

View File

@ -145,3 +145,25 @@ Array.prototype.diff = (a) ->
!!@_referenceForId(id).record
camelizeKeys: true
# TODO: the functions below will be added to Ember Model, remove them when that
# happens
resetData: ->
@_idToReference = null
@sideloadedData = null
@recordCache = null
@recordArrays = null
@_currentBatchIds = null
@_hasManyArrays = null
@_findAllRecordArray = null
unload: (record) ->
@removeFromRecordArrays(record)
primaryKey = record.get(get(this, 'primaryKey'))
@removeFromCache(primaryKey)
removeFromCache: (key) ->
if @sideloadedData && @sideloadedData[key]
delete this.sideloadedData[key]
if @recordCache && @recordCache[key]
delete this.recordCache[key]