From 3628bd5be86718c3d257152c15910499bd9ba409 Mon Sep 17 00:00:00 2001 From: Ritchie Date: Tue, 11 Jun 2013 11:11:10 -0700 Subject: [PATCH] Fix remoteEnabled bug --- lib/datasource.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/datasource.js b/lib/datasource.js index 062a4a61..4d37590a 100644 --- a/lib/datasource.js +++ b/lib/datasource.js @@ -73,7 +73,7 @@ function DataSource(name, settings) { accepts: fn.accepts, returns: fn.returns, http: fn.http, - remoteEnabled: fn.share, + remoteEnabled: fn.shared || false, fn: fn }); } @@ -282,8 +282,6 @@ DataSource.prototype.mixin = function (ModelCtor) { // mixin enabled operations as alias functions Object.keys(ops).forEach(function (name) { - console.log(name); - var op = ops[name]; var fn = op.fn; var scope; @@ -1177,9 +1175,10 @@ DataSource.prototype.enableRemote = function (operation) { DataSource.prototype.disable = function (operation) { var op = this.getOperation(operation); if(op) { - op.enabled = false; + op.enabled = + op.remoteEnabled = false; } else { - throw new Error(operation + ' is provided by the attached connector'); + throw new Error(operation + ' is not provided by the attached connector'); } } @@ -1192,7 +1191,7 @@ DataSource.prototype.disableRemote = function (operation) { if(op) { op.remoteEnabled = false; } else { - throw new Error(operation + ' is provided by the attached connector'); + throw new Error(operation + ' is not provided by the attached connector'); } } @@ -1202,9 +1201,10 @@ DataSource.prototype.disableRemote = function (operation) { DataSource.prototype.getOperation = function (operation) { var ops = this.operations(); + var opKeys = Object.keys(ops); - for(var i = 0; i < ops.length; i++) { - var op = ops[i]; + for(var i = 0; i < opKeys.length; i++) { + var op = ops[opKeys[i]]; if(op.name === operation) { return op; @@ -1226,6 +1226,7 @@ DataSource.prototype.operations = function () { DataSource.prototype.defineOperation = function (name, options, fn) { options.fn = fn; + options.name = name; options.enabled = true; this._operations[name] = options; }