diff --git a/lib/application.js b/lib/application.js index 4ed7b9f9..5e573ad2 100644 --- a/lib/application.js +++ b/lib/application.js @@ -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 = {}; - +} \ No newline at end of file