ModelBuilder: add `prototype.defineValueType`

Add a shortcut for registering a new value type.

The current implementation registers the type in the singleton registry
`ModelBuilder.schemaTypes`.

The API should allow us to to change the implementation to register
the type in the scope of ModelBuilder instance only.
This commit is contained in:
Miroslav Bajtoš 2014-05-23 13:18:06 +02:00
parent a86648ed7b
commit d8b4f5833a
1 changed files with 9 additions and 0 deletions

View File

@ -432,6 +432,15 @@ ModelBuilder.prototype.defineProperty = function (model, propertyName, propertyD
this.models[model].registerProperty(propertyName); this.models[model].registerProperty(propertyName);
}; };
/**
* Define a new value type that can be used in model schemas as a property type.
* @param {function()} type Type constructor.
* @param {string[]=} aliases Optional list of alternative names for this type.
*/
ModelBuilder.prototype.defineValueType = function(type, aliases) {
ModelBuilder.registerType(type, aliases);
};
/** /**
* Extend existing model with bunch of properties * Extend existing model with bunch of properties
* *