Fill ModelClass.http.path

Set the HTTP route to `'/' + pluralModelName` so that we don't have
to duplicate this bit of logic in strong-remoting and other places.
This commit is contained in:
Miroslav Bajtoš 2014-01-21 16:31:11 +01:00
parent 803821e736
commit dbb7c6d9ae
1 changed files with 4 additions and 2 deletions

View File

@ -109,7 +109,8 @@ ModelBuilder.prototype.getModelDefinition = function(name) {
ModelBuilder.prototype.define = function defineClass(className, properties, settings, parent) { ModelBuilder.prototype.define = function defineClass(className, properties, settings, parent) {
var modelBuilder = this; var modelBuilder = this;
var args = slice.call(arguments); var args = slice.call(arguments);
var pluralName = settings && settings.plural; var pluralName = (settings && settings.plural) ||
inflection.pluralize(className);
if (!className) { if (!className) {
throw new Error('Class name required'); throw new Error('Class name required');
@ -186,8 +187,9 @@ ModelBuilder.prototype.define = function defineClass(className, properties, sett
// Add metadata to the ModelClass // Add metadata to the ModelClass
hiddenProperty(ModelClass, 'modelBuilder', modelBuilder); hiddenProperty(ModelClass, 'modelBuilder', modelBuilder);
hiddenProperty(ModelClass, 'dataSource', modelBuilder); // Keep for back-compatibility hiddenProperty(ModelClass, 'dataSource', modelBuilder); // Keep for back-compatibility
hiddenProperty(ModelClass, 'pluralModelName', pluralName || inflection.pluralize(className)); hiddenProperty(ModelClass, 'pluralModelName', pluralName);
hiddenProperty(ModelClass, 'relations', {}); hiddenProperty(ModelClass, 'relations', {});
hiddenProperty(ModelClass, 'http', { path: '/' + pluralName });
// inherit ModelBaseClass static methods // inherit ModelBaseClass static methods
for (var i in ModelBaseClass) { for (var i in ModelBaseClass) {