Page MenuHomeSealhub

node_modules_prometheus-resource-type-manager_resource-type-manager.js.html
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

node_modules_prometheus-resource-type-manager_resource-type-manager.js.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: node_modules/prometheus-resource-type-manager/resource-type-manager.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: node_modules/prometheus-resource-type-manager/resource-type-manager.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* @module resource-type-manager
*/
var Set = require("Set");
var ResourceTypeManager = new function(){
var all_types = new Set();
var all_types_by_name = [];
function resource_type_name_correct(name){
return name.length>3 &amp;&amp; name.indexOf(" ")==-1;
}
/**
* Throws an error if a resource type of given name has not been registered
* @param {string} type_name the name of the resource type to check for existance of
*/
this.enforce_correct_type_name = function(type_name){
type_name = type_name.toString();
if(!ResourceTypeManager.typeExists(type_name)){
throw new Error("===ResourceTypeManager error===: type `" + type_name + "` does not exist.");
return;
}
};
/**
* Creates a new resource type
* @param {string} resource_type_name
* @param {object} fields
* @return {undefined}
*/
this.create = function(resource_type_name, fields){
if(!resource_type_name_correct(resource_type_name)){
throw new Error("===ReourceManager Error:===\tincorrect resource type name: " + resource_type_name.toString());
}
var new_resource = new ResourceType(resource_type_name, fields);
all_types.add(new_resource);
all_types_by_name[resource_type_name] = new_resource;
}
/**
* Get a resource type object by name
* @param {string} resource_type_name
* @return {ResourceType|null}
*/
this.getByName = function(resource_type_name){
var ret = all_types_by_name[resource_type_name] || null;
return ret;
};
/**
* Whether a resource type by given name has already been registered
* @param {string} resource_type_name
* @return {Boolean}
*/
this.typeExists = function(resource_type_name){
return all_types_by_name[resource_type_name]!==undefined;
};
}
module.exports = ResourceTypeManager;
var FieldTypeManager = require("prometheus-field-type-manager");
var ResourceType = require("prometheus-resource-type");</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-database-accessor.html">database-accessor</a></li><li><a href="module-field-type-manager.html">field-type-manager</a></li><li><a href="module-resource-type-manager.html">resource-type-manager</a></li></ul><h3>Classes</h3><ul><li><a href="AssociationInterface.html">AssociationInterface</a></li><li><a href="field-type-manager-Association.html">Association</a></li><li><a href="FieldType.html">FieldType</a></li><li><a href="Resource.html">Resource</a></li><li><a href="ResourceManager.html">ResourceManager</a></li><li><a href="ResourceType.html">ResourceType</a></li><li><a href="ResourceTypeField.html">ResourceTypeField</a></li></ul><h3>Global</h3><ul><li><a href="global.html#construct_resource_type">construct_resource_type</a></li></ul>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha11</a> on Mon Dec 08 2014 13:12:25 GMT+0100 (CET)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>

File Metadata

Mime Type
text/html
Expires
Fri, Nov 27, 15:27 (10 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1209609
Default Alt Text
node_modules_prometheus-resource-type-manager_resource-type-manager.js.html (3 KB)

Event Timeline