[#17,backend][s]: add readonly attribute on backends indicating whether they are 'read-only'.
This commit is contained in:
@@ -32,6 +32,13 @@ this.recline.Backend = this.recline.Backend || {};
|
||||
// backends (see recline.Model.Dataset.initialize).
|
||||
__type__: 'base',
|
||||
|
||||
|
||||
// ### readonly
|
||||
//
|
||||
// Class level attribute indicating that this backend is read-only (that
|
||||
// is, cannot be written to).
|
||||
readonly: true,
|
||||
|
||||
// ### sync
|
||||
//
|
||||
// An implementation of Backbone.sync that will be used to override
|
||||
|
||||
@@ -18,6 +18,7 @@ this.recline.Backend = this.recline.Backend || {};
|
||||
// Note that this is a **read-only** backend.
|
||||
my.DataProxy = my.Base.extend({
|
||||
__type__: 'dataproxy',
|
||||
readonly: true,
|
||||
defaults: {
|
||||
dataproxy_url: 'http://jsonpdataproxy.appspot.com'
|
||||
},
|
||||
|
||||
@@ -21,6 +21,7 @@ this.recline.Backend = this.recline.Backend || {};
|
||||
// <pre>http://localhost:9200/twitter/tweet</pre>
|
||||
my.ElasticSearch = my.Base.extend({
|
||||
__type__: 'elasticsearch',
|
||||
readonly: true,
|
||||
_getESUrl: function(dataset) {
|
||||
var out = dataset.get('elasticsearch_url');
|
||||
if (out) return out;
|
||||
|
||||
@@ -18,6 +18,7 @@ this.recline.Backend = this.recline.Backend || {};
|
||||
// </pre>
|
||||
my.GDoc = my.Base.extend({
|
||||
__type__: 'gdoc',
|
||||
readonly: true,
|
||||
getUrl: function(dataset) {
|
||||
var url = dataset.get('url');
|
||||
if (url.indexOf('feeds/list') != -1) {
|
||||
|
||||
@@ -71,6 +71,7 @@ this.recline.Backend = this.recline.Backend || {};
|
||||
// </pre>
|
||||
my.Memory = my.Base.extend({
|
||||
__type__: 'memory',
|
||||
readonly: false,
|
||||
initialize: function() {
|
||||
this.datasets = {};
|
||||
},
|
||||
|
||||
@@ -25,6 +25,11 @@ function makeBackendDataset() {
|
||||
return dataset;
|
||||
}
|
||||
|
||||
test('Memory Backend: readonly', function () {
|
||||
var backend = new recline.Backend.Memory();
|
||||
equal(backend.readonly, false);
|
||||
});
|
||||
|
||||
test('Memory Backend: createDataset', function () {
|
||||
var dataset = recline.Backend.createDataset(memoryData.documents, memoryData.fields, memoryData.metadata);
|
||||
equal(memoryData.metadata.id, dataset.id);
|
||||
@@ -217,6 +222,8 @@ test('DataProxy Backend', function() {
|
||||
// needed only if not stubbing
|
||||
// stop();
|
||||
var backend = new recline.Backend.DataProxy();
|
||||
ok(backend.readonly, false);
|
||||
|
||||
var dataset = new recline.Model.Dataset({
|
||||
url: 'http://webstore.thedatahub.org/rufuspollock/gold_prices/data.csv'
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user