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;
@ -60,7 +86,7 @@ Model.sharedCtor = function (data, id, fn) {
}
// before remote hook
Model.beforeRemote = function (name, fn) {
ModelCtor.beforeRemote = function (name, fn) {
var self = this;
if(this.app) {
var remotes = this.app.remotes();
@ -75,34 +101,6 @@ Model.beforeRemote = function (name, 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 = [];
ModelCtor.sharedCtor.accepts = [
{arg: 'data', type: 'object', http: {source: 'body'}},
{arg: 'id', type: 'any', http: {source: 'url'}}

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);