Manually merge application

This commit is contained in:
Ritchie 2013-07-17 14:30:38 -07:00
parent 7c7667151a
commit f7791fc366
1 changed files with 14 additions and 63 deletions

View File

@ -25,21 +25,6 @@ app.remotes = function () {
}
}
/**
* Expose an object or Class remotely.
*
* @param {String} name The remote namespace (eg. url base)
* @param {Object|Function} obj The object to remote
*/
app.remote = function (name, obj) {
// add the object to the remote exports
this.remotes().exports[name] = obj;
// clear the handlers cache
this._handlers = {};
}
/**
* Remove a route by reference.
*/
@ -59,7 +44,6 @@ app.disuse = function (route) {
*/
app._models = [];
app._services = [];
/**
* Expose a model.
@ -68,8 +52,6 @@ app._services = [];
*/
app.model = function (Model) {
var remotes = this.remotes();
this._models.push(Model);
Model.shared = true;
Model.app = this;
@ -85,28 +67,22 @@ app.models = function () {
}
/**
* Expose a service.
*
* @param {String} name
* @param {Service} service
* Get all remote objects.
*/
app.service = function (name, service) {
this._services.push(service);
service.shared = true;
app.remoteObjects = function () {
var result = {};
var models = this.models();
service.app = this;
// add to the remote exports
this.remote(name, service);
}
/**
* Get all exposed services.
*/
app.services = function () {
return this._services;
// add in models
models.forEach(function (ModelCtor) {
// only add shared models
if(ModelCtor.shared && typeof ModelCtor.sharedCtor === 'function') {
result[ModelCtor.pluralModelName] = ModelCtor;
}
});
return result;
}
/**
@ -115,29 +91,4 @@ app.services = function () {
app.remotes = function () {
return this._remotes || (this._remotes = RemoteObjects.create());
}
/**
* Get a remotes handler.
*/
app.handler = function (type) {
var handler = this._handlers[type];
if(!handler) {
// get the sl remoting object
var remotes = this.remotes();
// create and save the handler
handler = this._handlers[type] = remotes.handler(type);
}
return handler;
}
/*!
* Handlers
*/
app._handlers = {};
}