lib/server/apiadapter-mixin.js
function sync(method, model, options) {
	var url = options.url || _.result(model, 'url')
		, httpMethod = methodMap[method]
		, data;

	debug('syncing (method: `%s`, httpMethod: `%s`, url: `%s`, model: `%j`)'
		, method, httpMethod, url, model);

	if(_.isUndefined(url)) {
		throw new Error('No url present for syncing!', model, options);
	}

	if(method !== 'read' && method !== 'delete') {
		data = model.toJSON();
	}

	this.dispatchLocalApiCall(httpMethod, url, data, options);
}
function sync(method, model, options) {
	var url = options.url || _.result(model, 'url')
		, httpMethod = methodMap[method]
		, data;

	debug('syncing (method: `%s`, httpMethod: `%s`, url: `%s`, model: `%j`)'
		, method, httpMethod, url, model);

	if(_.isUndefined(url)) {
		throw new Error('No url present for syncing!', model, options);
	}

	if(method !== 'read' && method !== 'delete') {
		data = model.toJSON();
	}

	this.dispatchLocalApiCall(httpMethod, url, data, options);
}
function sync ( method , model , options ) { var url = options . url || _ . result ( model , 'url' ) , httpMethod = methodMap [ method ] , data ; debug ( 'syncing (method: `%s`, httpMethod: `%s`, url: `%s`, model: `%j`)' , method , httpMethod , url , model ) ; if ( _ . isUndefined ( url ) ) { throw new Error ( 'No url present for syncing!' , model , options ) ; } if ( method !== 'read' && method !== 'delete' ) { data = model . toJSON ( ) ; } this . dispatchLocalApiCall ( httpMethod , url , data , options ) ; }
Function: sync
During startup on the server, this function replaces Backbones own sync
implementation to shortcut "local" API calls.

Instead going the detour over an AJAX request, this implementation of sync
calls the API callback directly by resolving the models URL with the present
apiRoutes.

If method is not equal to read or delete, the return value of the toJSON
function of the given model is passed to the API callback.

Parameters:
(String) method - A method (create, update, patch, delete or read) which
will be used to resolve the models URL properly.
(Backbone.Model) model - The model which wants to be synced. Can also be
an instance of Backbone.Collection.
(Object) options - Should contain at least a success callback. Any api
callback result will be delivered as argument of the
success function.
Function : sync During startup on the server this function replaces Backbones own sync implementation to shortcut local API calls .