Sha256: 3cf633192c630830b7bad9c722dd22ba7a69ee5e1800d99a889d1ae6182408ff
Contents?: true
Size: 891 Bytes
Versions: 14
Compression:
Stored size: 891 Bytes
Contents
class @TypeStation.Store constructor: (@id = null) -> @STORE = {} get: (key) -> @STORE[key] set: (key, value) -> @STORE[key] = value each: (callback) -> for key, value of @STORE callback?(key, value) class @TypeStation.Model extends @TypeStation.Store constructor: (@id = null) -> super @DIRTY = {} set: (key, value) -> super key, value @DIRTY[key] = 1 changedKeys: -> Object.keys(@DIRTY) isChanged: -> @changedKeys().length > 0 _reset: -> @STORE = {} @DIRTY = {} save: (callback = ->) -> self = @ data = [] for key, value of @STORE data.push(value) $.ajax type: "PATCH" url: self.id dataType: 'json' contentType: 'application/json' data: JSON.stringify({contents: data}) success: (data) -> self._reset() #reset model to a clean state callback(data)
Version data entries
14 entries across 14 versions & 1 rubygems