Commit 1527f4a9 authored by Tristan Cavelier's avatar Tristan Cavelier

jslint pass storage.js

parent ac79eed3
var storage = function(spec, my) {
var that = {};
/*jslint indent: 2, maxlen: 80, sloppy: true */
/*global command: true, jobManager: true, job: true */
var storage = function (spec, my) {
var that = {}, priv = {};
spec = spec || {};
my = my || {};
// Attributes //
var priv = {};
priv.type = spec.type || '';
// Methods //
Object.defineProperty(that,"getType",{
configurable:false,enumerable:false,writable:false,value:
function() {
Object.defineProperty(that, "getType", {
configurable: false,
enumerable: false,
writable: false,
value: function () {
return priv.type;
}
});
......@@ -19,7 +22,7 @@ var storage = function(spec, my) {
* @method execute
* @param {object} command The command
*/
that.execute = function(command) {
that.execute = function (command) {
that.success = command.success;
that.error = command.error;
that.retry = command.retry;
......@@ -34,7 +37,7 @@ var storage = function(spec, my) {
* @method isValid
* @return {boolean} true if ok, else false.
*/
that.isValid = function() {
that.isValid = function () {
return true;
};
......@@ -42,9 +45,11 @@ var storage = function(spec, my) {
var mess = that.validateState();
if (mess) {
that.error({
status:0,statusText:'Invalid Storage',
error:'invalid_storage',
message:mess,reason:mess
"status": 0,
"statusText": "Invalid Storage",
"error": "invalid_storage",
"message": mess,
"reason": mess
});
return false;
}
......@@ -56,9 +61,9 @@ var storage = function(spec, my) {
* @method serialized
* @return {object} The serialized storage.
*/
that.serialized = function() {
that.serialized = function () {
var o = that.specToStore() || {};
o["type"] = that.getType();
o.type = that.getType();
return o;
};
......@@ -78,7 +83,7 @@ var storage = function(spec, my) {
* @method validateState
* @return {string} empty: ok, else error message.
*/
that.validateState = function() {
that.validateState = function () {
return '';
};
......@@ -154,24 +159,24 @@ var storage = function(spec, my) {
});
};
that.success = function() {};
that.retry = function() {};
that.error = function() {};
that.end = function() {}; // terminate the current job.
that.success = function () {};
that.retry = function () {};
that.error = function () {};
that.end = function () {}; // terminate the current job.
priv.newCommand = function (method, spec) {
var o = spec || {};
o.label = method;
return command (o, my);
return command(o, my);
};
priv.storage = my.storage;
delete my.storage;
that.addJob = function (method,storage_spec,doc,option,success,error) {
that.addJob = function (method, storage_spec, doc, option, success, error) {
var command_opt = {
options: option,
callbacks:{success:success,error:error}
callbacks: {success: success, error: error}
};
if (doc) {
if (method === 'get') {
......@@ -180,12 +185,10 @@ var storage = function(spec, my) {
command_opt.doc = doc;
}
}
jobManager.addJob (
job({
storage:priv.storage(storage_spec||{}),
command:priv.newCommand(method,command_opt)
}, my)
);
jobManager.addJob(job({
storage: priv.storage(storage_spec || {}),
command: priv.newCommand(method, command_opt)
}, my));
};
return that;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment