[Code Style] Use prototypes in containment bundle

WTD-1482.
This commit is contained in:
Victor Woeltjen
2015-08-11 11:01:13 -07:00
parent aa08db1050
commit f377c7cb71
6 changed files with 94 additions and 114 deletions

View File

@ -36,7 +36,7 @@ define(
* @memberof platform/containment
*/
function CapabilityTable(typeService, capabilityService) {
var table = {};
var self = this;
// Build an initial model for a type
function buildModel(type) {
@ -54,26 +54,26 @@ define(
function addToTable(type) {
var typeKey = type.getKey();
Object.keys(getCapabilities(type)).forEach(function (key) {
table[key] = table[key] || {};
table[key][typeKey] = true;
self.table[key] = self.table[key] || {};
self.table[key][typeKey] = true;
});
}
// Build the table
this.table = {};
(typeService.listTypes() || []).forEach(addToTable);
return {
/**
* Check if a type is expected to expose a specific
* capability.
* @memberof platform/containment.CapabilityTable#
*/
hasCapability: function (typeKey, capabilityKey) {
return (table[capabilityKey] || {})[typeKey];
}
};
}
/**
* Check if a type is expected to expose a specific capability.
* @param {string} typeKey the type identifier
* @param {string} capabilityKey the capability identifier
* @returns {boolean} true if expected to be exposed
*/
CapabilityTable.prototype.hasCapability = function (typeKey, capabilityKey) {
return (this.table[capabilityKey] || {})[typeKey];
};
return CapabilityTable;
}
);