Page MenuHomeSealhub

bin_node_modules_prometheus-resource-type_resource-type.js.html
No OneTemporary

Authored By
Unknown
Size
10 KB
Referenced Files
None
Subscribers
None

bin_node_modules_prometheus-resource-type_resource-type.js.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>bin/node_modules/prometheus-resource-type/resource-type.js - Prometheus Framework</title>
<link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
<script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">
<div id="doc">
<div id="hd" class="yui3-g header">
<div class="yui3-u-3-4">
<h1><img src="../assets/css/logo.png" title="Prometheus Framework"></h1>
</div>
<div class="yui3-u-1-4 version">
<em>API Docs for: 0.1</em>
</div>
</div>
<div id="bd" class="yui3-g">
<div class="yui3-u-1-4">
<div id="docs-sidebar" class="sidebar apidocs">
<div id="api-list">
<h2 class="off-left">APIs</h2>
<div id="api-tabview" class="tabview">
<ul class="tabs">
<li><a href="#api-classes">Classes</a></li>
<li><a href="#api-modules">Modules</a></li>
</ul>
<div id="api-tabview-filter">
<input type="search" id="api-filter" placeholder="Type to filter APIs">
</div>
<div id="api-tabview-panel">
<ul id="api-classes" class="apis classes">
<li><a href="../classes/Represents a
Replicaset Configuration.html">Represents a
Replicaset Configuration</a></li>
<li><a href="../classes/Represents a BatchWriteResult.html">Represents a BatchWriteResult</a></li>
<li><a href="../classes/Represents a Collection.html">Represents a Collection</a></li>
<li><a href="../classes/Represents a Cursor..html">Represents a Cursor.</a></li>
<li><a href="../classes/Represents a CursorStream..html">Represents a CursorStream.</a></li>
<li><a href="../classes/Represents a Db.html">Represents a Db</a></li>
<li><a href="../classes/Represents a GridFS File Stream..html">Represents a GridFS File Stream.</a></li>
<li><a href="../classes/.html"></a></li>
<li><a href="../classes/Represents a MongoClient.html">Represents a MongoClient</a></li>
<li><a href="../classes/Represents a Mongos connection with failover to backup proxies.html">Represents a Mongos connection with failover to backup proxies</a></li>
<li><a href="../classes/Represents a OrderedBulkOperation.html">Represents a OrderedBulkOperation</a></li>
<li><a href="../classes/Represents a Read Preference..html">Represents a Read Preference.</a></li>
<li><a href="../classes/Represents a Server connection..html">Represents a Server connection.</a></li>
<li><a href="../classes/Represents a UnorderedBulkOperation.html">Represents a UnorderedBulkOperation</a></li>
<li><a href="../classes/Represents the Admin methods of MongoDB..html">Represents the Admin methods of MongoDB.</a></li>
<li><a href="../classes/Represents the Grid..html">Represents the Grid.</a></li>
<li><a href="../classes/Represents the GridStore..html">Represents the GridStore.</a></li>
</ul>
<ul id="api-modules" class="apis modules">
<li><a href="../modules/association.html">association</a></li>
<li><a href="../modules/database-accessor.html">database-accessor</a></li>
<li><a href="../modules/field-type-manager.html">field-type-manager</a></li>
<li><a href="../modules/resource-type-manager.html">resource-type-manager</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="yui3-u-3-4">
<div id="api-options">
Show:
<label for="api-show-inherited">
<input type="checkbox" id="api-show-inherited" checked>
Inherited
</label>
<label for="api-show-protected">
<input type="checkbox" id="api-show-protected">
Protected
</label>
<label for="api-show-private">
<input type="checkbox" id="api-show-private">
Private
</label>
<label for="api-show-deprecated">
<input type="checkbox" id="api-show-deprecated">
Deprecated
</label>
</div>
<div class="apidocs">
<div id="docs-main">
<div class="content">
<h1 class="file-heading">File: bin/node_modules/prometheus-resource-type/resource-type.js</h1>
<div class="file">
<pre class="code prettyprint linenums">
var Promise = require(&quot;promise&quot;);
var FieldTypeManager = require(&quot;prometheus-field-type-manager&quot;);
var ResourceTypeField = require(&quot;prometheus-resource-type-field&quot;);
/**
* Represents a Resource type. Contains Fields of specified type.
* @class
* @param {string} name Must be a unique string
* @param {Object} field_declarations
*/
function ResourceType(name, field_declarations){
this.name = name;
this.fields = [];
this.parseFieldDeclarations(field_declarations);
}
ResourceType.prototype = new function(){
this.parseFieldDeclarations = function(field_declarations){
var ret = [];
for(var field_name in field_declarations){
var new_field = new ResourceTypeField(field_name, field_declarations[field_name]);
this.addField(new_field);
}
return ret;
}
/**
* Adds a field to the ResourceType instance
* @name ResourceType#addField
* @param {string} field_object the field to append to ResourceType Description
*/
this.addField = function(field_object){
if(this.fields[field_object.name]!==undefined){
throw new Error(&quot;===ResourceType error===: field &#x60;&quot; + field_object.name + &quot;&#x60; already exists&quot;);
}
this.fields[field_object.name] = field_object;
}
/**
* Checks if given field_values can be stored in this Resource Type
* @name ResourceType#validateFieldValues
* @param {object} field_values
* @return {Promise} resolved if field values are valid, rejected otherwise
*/
this.validateFieldValues = function(field_values){
return new Promise(function(resolve, reject){
for(var field_name in field_values){
if(!this.fields[field_name]){
var err = new Error(&quot;===error=== type &#x60;&quot; + this.name + &quot;&#x60; does not have a field with a name &#x60;&quot; + field_name + &quot;&#x60;&quot;);
err.code = &quot;unknown_field_name&quot;;
reject(err);
return;
}
}
for(field_name in this.fields){
var current_field = this.fields[field_name];
if(current_field.required &amp;&amp; field_values[field_name]===undefined){
var err2 = new Error(&quot;===error=== value for field &#x60;&quot; + field_name + &quot;&#x60; in &#x60;&quot; + this.name + &quot;&#x60; not set!&quot;);
err2.code = &quot;missing_field_value&quot;;
reject(err2);
return;
}
}
resolve();
});
}
}
module.exports = ResourceType;
</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>

File Metadata

Mime Type
text/html
Expires
Sat, Nov 28, 01:29 (23 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1227252
Default Alt Text
bin_node_modules_prometheus-resource-type_resource-type.js.html (10 KB)

Event Timeline