Model sharedCtor arg handleing
This commit is contained in:
parent
463bc45d3e
commit
087e3eabcb
|
@ -114,17 +114,27 @@ app.define = function (name, properties, options) {
|
|||
};
|
||||
|
||||
ModelCtor.shared = true;
|
||||
ModelCtor.sharedCtor = function (id, fn) {
|
||||
if(id) {
|
||||
ModelCtor.sharedCtor = function (data, id, fn) {
|
||||
if(typeof data === 'function') {
|
||||
fn = data;
|
||||
data = null;
|
||||
id = null;
|
||||
} else if (typeof id === 'function') {
|
||||
fn = id;
|
||||
id = null;
|
||||
}
|
||||
|
||||
if(data) {
|
||||
fn(null, new ModelCtor(data));
|
||||
} else if(id) {
|
||||
ModelCtor.find(id, fn);
|
||||
} else {
|
||||
fn(null, new ModelCtor(data));
|
||||
fn(new Error('must specify an id or data'));
|
||||
}
|
||||
};
|
||||
ModelCtor.sharedCtor.accepts = [
|
||||
// todo... models need to expose what id type they need
|
||||
{arg: 'id', type: 'any'},
|
||||
{arg: 'data', type: 'object'}
|
||||
{arg: 'data', type: 'object'},
|
||||
{arg: 'id', type: 'any'}
|
||||
];
|
||||
ModelCtor.sharedCtor.http = [
|
||||
{path: '/'},
|
||||
|
|
Loading…
Reference in New Issue