Created
August 21, 2012 18:33
Revisions
-
hmaurer created this gist
Aug 21, 2012 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ Foo = {} Foo.DataSource = {} class Foo.DataSource.REST (baseUrl) -> @baseUrl = baseUrl fetchAll: !-> @doRequest("GET", @baseUrl, { success: (data, event, response) -> console.debug data }) fetch: !(id) -> @doRequest("GET", this.baseUrl + "/" + id) create: !(data) -> @doRequest("POST", this.baseUrl, {data: data}) update: !(id, data) -> @doRequest("PUT", this.baseUrl + "/" + id, {data: data}) delete: !(id) -> @doRequest("DELETE", this.baseUrl + "/" + id) doRequest: (method, url, options) -> $.ajax({ type: method, url: url } <<< options)