[#50,backend,refactor][s]: complete backend split / rename refactor by removing Backend prefix from Backend classes - fixes #50.
* Backend prefix unnecessary now that everything in recline.Backend module.
This commit is contained in:
@@ -62,7 +62,7 @@ function demoDataset() {
|
|||||||
, {id: 5, x: 6, y: 12, z: 18}
|
, {id: 5, x: 6, y: 12, z: 18}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
var backend = new recline.Backend.BackendMemory();
|
var backend = new recline.Backend.Memory();
|
||||||
backend.addDataset(inData);
|
backend.addDataset(inData);
|
||||||
var dataset = new recline.Model.Dataset({id: datasetId}, backend);
|
var dataset = new recline.Model.Dataset({id: datasetId}, backend);
|
||||||
return dataset;
|
return dataset;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ this.recline = this.recline || {};
|
|||||||
this.recline.Backend = this.recline.Backend || {};
|
this.recline.Backend = this.recline.Backend || {};
|
||||||
|
|
||||||
(function($, my) {
|
(function($, my) {
|
||||||
// ## BackendDataProxy
|
// ## DataProxy Backend
|
||||||
//
|
//
|
||||||
// For connecting to [DataProxy-s](http://github.com/okfn/dataproxy).
|
// For connecting to [DataProxy-s](http://github.com/okfn/dataproxy).
|
||||||
//
|
//
|
||||||
@@ -16,7 +16,7 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
// * format: (optional) csv | xls (defaults to csv if not specified)
|
// * format: (optional) csv | xls (defaults to csv if not specified)
|
||||||
//
|
//
|
||||||
// Note that this is a **read-only** backend.
|
// Note that this is a **read-only** backend.
|
||||||
my.BackendDataProxy = Backbone.Model.extend({
|
my.DataProxy = Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
dataproxy_url: 'http://jsonpdataproxy.appspot.com'
|
dataproxy_url: 'http://jsonpdataproxy.appspot.com'
|
||||||
},
|
},
|
||||||
@@ -79,7 +79,7 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
return dfd.promise();
|
return dfd.promise();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
recline.Model.backends['dataproxy'] = new my.BackendDataProxy();
|
recline.Model.backends['dataproxy'] = new my.DataProxy();
|
||||||
|
|
||||||
|
|
||||||
}(jQuery, this.recline.Backend));
|
}(jQuery, this.recline.Backend));
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
// 'gdocs'
|
// 'gdocs'
|
||||||
// );
|
// );
|
||||||
// </pre>
|
// </pre>
|
||||||
my.BackendGDoc = Backbone.Model.extend({
|
my.GDoc = Backbone.Model.extend({
|
||||||
sync: function(method, model, options) {
|
sync: function(method, model, options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (method === "read") {
|
if (method === "read") {
|
||||||
@@ -111,7 +111,7 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
recline.Model.backends['gdocs'] = new my.BackendGDoc();
|
recline.Model.backends['gdocs'] = new my.GDoc();
|
||||||
|
|
||||||
}(jQuery, this.recline.Backend));
|
}(jQuery, this.recline.Backend));
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,8 @@
|
|||||||
// # Recline Backends
|
|
||||||
//
|
|
||||||
// Backends are connectors to backend data sources and stores
|
|
||||||
//
|
|
||||||
// Backends are implemented as Backbone models but this is just a
|
|
||||||
// convenience (they do not save or load themselves from any remote
|
|
||||||
// source)
|
|
||||||
this.recline = this.recline || {};
|
this.recline = this.recline || {};
|
||||||
this.recline.Backend = this.recline.Backend || {};
|
this.recline.Backend = this.recline.Backend || {};
|
||||||
|
|
||||||
(function($, my) {
|
(function($, my) {
|
||||||
// ## BackendMemory - uses in-memory data
|
// ## Memory Backend - uses in-memory data
|
||||||
//
|
//
|
||||||
// This is very artificial and is really only designed for testing
|
// This is very artificial and is really only designed for testing
|
||||||
// purposes.
|
// purposes.
|
||||||
@@ -23,7 +16,7 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
//
|
//
|
||||||
// <pre>
|
// <pre>
|
||||||
// // Backend setup
|
// // Backend setup
|
||||||
// var backend = Backend();
|
// var backend = recline.Backend.Memory();
|
||||||
// backend.addDataset({
|
// backend.addDataset({
|
||||||
// metadata: {
|
// metadata: {
|
||||||
// id: 'my-id',
|
// id: 'my-id',
|
||||||
@@ -40,7 +33,7 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
// dataset.fetch();
|
// dataset.fetch();
|
||||||
// etc ...
|
// etc ...
|
||||||
// </pre>
|
// </pre>
|
||||||
my.BackendMemory = Backbone.Model.extend({
|
my.Memory = Backbone.Model.extend({
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.datasets = {};
|
this.datasets = {};
|
||||||
},
|
},
|
||||||
@@ -82,7 +75,7 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
}
|
}
|
||||||
return dfd.promise();
|
return dfd.promise();
|
||||||
} else {
|
} else {
|
||||||
alert('Not supported: sync on BackendMemory with method ' + method + ' and model ' + model);
|
alert('Not supported: sync on Memory backend with method ' + method + ' and model ' + model);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
query: function(model, queryObj) {
|
query: function(model, queryObj) {
|
||||||
@@ -102,6 +95,6 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
return dfd.promise();
|
return dfd.promise();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
recline.Model.backends['memory'] = new my.BackendMemory();
|
recline.Model.backends['memory'] = new my.Memory();
|
||||||
|
|
||||||
}(jQuery, this.recline.Backend));
|
}(jQuery, this.recline.Backend));
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ this.recline = this.recline || {};
|
|||||||
this.recline.Backend = this.recline.Backend || {};
|
this.recline.Backend = this.recline.Backend || {};
|
||||||
|
|
||||||
(function($, my) {
|
(function($, my) {
|
||||||
// ## BackendWebstore
|
// ## Webstore Backend
|
||||||
//
|
//
|
||||||
// Connecting to [Webstores](http://github.com/okfn/webstore)
|
// Connecting to [Webstores](http://github.com/okfn/webstore)
|
||||||
//
|
//
|
||||||
// To use this backend ensure your Dataset has a webstore_url in its attributes.
|
// To use this backend ensure your Dataset has a webstore_url in its attributes.
|
||||||
my.BackendWebstore = Backbone.Model.extend({
|
my.Webstore = Backbone.Model.extend({
|
||||||
sync: function(method, model, options) {
|
sync: function(method, model, options) {
|
||||||
if (method === "read") {
|
if (method === "read") {
|
||||||
if (model.__type__ == 'Dataset') {
|
if (model.__type__ == 'Dataset') {
|
||||||
@@ -56,6 +56,6 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
return dfd.promise();
|
return dfd.promise();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
recline.Model.backends['webstore'] = new my.BackendWebstore();
|
recline.Model.backends['webstore'] = new my.Webstore();
|
||||||
|
|
||||||
}(jQuery, this.recline.Backend));
|
}(jQuery, this.recline.Backend));
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ var memoryData = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function makeBackendDataset() {
|
function makeBackendDataset() {
|
||||||
var backend = new recline.Backend.BackendMemory();
|
var backend = new recline.Backend.Memory();
|
||||||
backend.addDataset(memoryData);
|
backend.addDataset(memoryData);
|
||||||
var dataset = new recline.Model.Dataset({id: memoryData.metadata.id}, backend);
|
var dataset = new recline.Model.Dataset({id: memoryData.metadata.id}, backend);
|
||||||
return dataset;
|
return dataset;
|
||||||
|
|||||||
Reference in New Issue
Block a user