Sha256: c32b6957deff6207da71a6c755aa501f7491e12c6f52b771eaed82a9d8a4cacc

Contents?: true

Size: 571 Bytes

Versions: 3

Compression:

Stored size: 571 Bytes

Contents

class window.TS.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 window.TS.Model extends window.TS.Store
  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) -> callback(data)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
type_station-0.0.3 app/assets/javascripts/type_station/lib/models.js.coffee
type_station-0.0.2 app/assets/javascripts/type_station/lib/models.js.coffee
type_station-0.0.1 app/assets/javascripts/type_station/lib/models.js.coffee