Files
openmct/example/policy/src/ExamplePolicy.js
Victor Woeltjen 00551779fb [Policy] Add example of usage
Add example showing usage of policy, WTD-973.
2015-04-01 15:18:20 -07:00

26 lines
752 B
JavaScript

/*global define*/
define(
[],
function () {
"use strict";
function ExamplePolicy() {
return {
/**
* Disallow the Remove action on objects whose name contains
* "foo."
*/
allow: function (action, context) {
var domainObject = (context || {}).domainObject,
model = (domainObject && domainObject.getModel()) || {},
name = model.name || "",
metadata = action.getMetadata() || {};
return metadata.key !== 'remove' || name.indexOf('foo') < 0;
}
};
}
return ExamplePolicy;
}
);