 #    May be freely distributed according to MIT license.
 
 window.Offline =
-  VERSION: '0.3.0.beta'
+  VERSION: '0.4.0.alfa'
 
   # This is a method for CRUD operations with localStorage.
   # Delegates to 'Offline.Storage' and works as ‘Backbone.sync’ alternative

  # and sends every object to server using 'Backbone.sync' method
  # after that it sends deleted objects to the server
  push: ->
    this.pushItem(item) for item in @collection.dirty()
    this.flushItem(sid) for sid in @storage.destroyIds.values

  pushItem: (item) ->
    @storage.replaceKeyFields(item, 'server')

    delete item.attributes.id
    [method, item.id] = if item.get('sid') is 'new' then ['create', null] else ['update', item.attributes.sid]

    @ajax method, item, success: (response, status, xhr) =>
      item.set(sid: response.id) if method is 'create'
      item.save {dirty: false}, {local: true}

