[Containment] Add general policy for containment rules

Add general policy for supporting containment rules, WTD-962.
This commit is contained in:
Victor Woeltjen
2015-04-07 19:58:39 -07:00
parent 3c3dd0ad17
commit 3c00eb86ea
4 changed files with 182 additions and 0 deletions

View File

@ -0,0 +1,29 @@
/*global define*/
define(
['./ContainmentTable'],
function (ContainmentTable) {
"use strict";
/**
* Defines composition policy as driven by type metadata.
*/
function CompositionPolicy(typeService, capabilityService) {
// We're really just wrapping the containment table and rephrasing
// it as a policy decision.
var table = new ContainmentTable(typeService, capabilityService);
return {
/**
* Is the type identified by the candidate allowed to
* contain the type described by the context?
*/
allow: function (candidate, context) {
return table.canContain(candidate, context);
}
};
}
return CompositionPolicy;
}
);