Remove updateAttribute as remote method

This commit is contained in:
Ritchie Martori 2013-07-15 19:45:27 -07:00
parent 49da6f4249
commit fbf0e35f1d
2 changed files with 56 additions and 59 deletions

View File

@ -17,9 +17,35 @@ Model.shared = true;
* For **remoting**. Construct objects when calling instance methods remotely.
*/
Model.sharedCtor = function (data, id, fn) {
// after remote hook
Model.afterRemote = function (name, fn) {
var self = this;
if(this.app) {
var remotes = this.app.remotes();
remotes.after(self.pluralModelName + '.' + name, function (ctx, next) {
fn(ctx, ctx.result, next);
});
} else {
var args = arguments;
this.once('attached', function () {
self.afterRemote.apply(self, args);
});
}
}
/*!
* Called when a model is extended.
*/
Model.setup = function () {
var ModelCtor = this;
// each model has its
// own access control
// list
Model.acl = [];
Model.sharedCtor = function (data, id, fn) {
if(typeof data === 'function') {
fn = data;
data = null;
@ -57,10 +83,10 @@ Model.sharedCtor = function (data, id, fn) {
} else {
fn(new Error('must specify an id or data'));
}
}
}
// before remote hook
Model.beforeRemote = function (name, fn) {
// before remote hook
ModelCtor.beforeRemote = function (name, fn) {
var self = this;
if(this.app) {
var remotes = this.app.remotes();
@ -73,35 +99,7 @@ Model.beforeRemote = function (name, fn) {
self.beforeRemote.apply(self, args);
});
}
}
// after remote hook
Model.afterRemote = function (name, fn) {
var self = this;
if(this.app) {
var remotes = this.app.remotes();
remotes.after(self.pluralModelName + '.' + name, function (ctx, next) {
fn(ctx, ctx.result, next);
});
} else {
var args = arguments;
this.once('attached', function () {
self.afterRemote.apply(self, args);
});
}
}
/*!
* Called when a model is extended.
*/
Model.setup = function () {
var ModelCtor = this;
// each model has its
// own access control
// list
Model.acl = [];
ModelCtor.sharedCtor.accepts = [
{arg: 'data', type: 'object', http: {source: 'body'}},

View File

@ -61,7 +61,6 @@ describe('DataSource', function() {
existsAndShared('isNewRecord', false);
existsAndShared('_adapter', false);
existsAndShared('destroy', true);
existsAndShared('updateAttribute', true);
existsAndShared('updateAttributes', true);
existsAndShared('reload', true);