From ec58237f8a51af7ea92313285dfb5b70bc94eccc Mon Sep 17 00:00:00 2001 From: Ritchie Martori Date: Mon, 18 Nov 2013 12:52:00 -0800 Subject: [PATCH] Add public flag checking --- docs/api.md | 7 +++++++ lib/application.js | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/api.md b/docs/api.md index 71a6e8b3..0bbaca35 100644 --- a/docs/api.md +++ b/docs/api.md @@ -113,6 +113,13 @@ The following is an example of an object containing two `Model` definitions: "lo Define a `Model` and export it for use by remote clients. +**definition** + + - `public` - **default: true** attach the `Model` to the app and export its methods to clients + - `dataSource` - **required** the name of the `DataSource` to attach the `Model` to + +**Example** + ```js // declare a DataSource app.boot({ diff --git a/lib/application.js b/lib/application.js index 590b83ab..29cb46b7 100644 --- a/lib/application.js +++ b/lib/application.js @@ -67,6 +67,7 @@ app.model = function (Model, config) { return; } var modelName = Model; + config = config || {}; assert(typeof modelName === 'string', 'app.model(name, config) => "name" name must be a string'); Model = @@ -74,7 +75,9 @@ app.model = function (Model, config) { this.models[classify(modelName)] = this.models[camelize(modelName)] = modelFromConfig(modelName, config, this); - this.model(Model); + if(config.public !== false) { + this.model(Model); + } return Model; }