[Core] Add JSDoc for ContextualDomainObject

Add JSDoc for the domain object wrapper used to
expose a 'context' capability; part of
ongoing documentation to meet code standards in
platform/core in preparation for integration.
WTD-573.
This commit is contained in:
Victor Woeltjen 2014-11-20 13:56:23 -08:00
parent e569249231
commit b9651b45d0

View File

@ -9,14 +9,28 @@ define(
"use strict"; "use strict";
/** /**
* Wraps a domain object, such that it exposes a `context` capability.
* A domain object may be contained by multiple other domain objects;
* the `context` capability allows two instances of the same domain
* object to be distinguished from one another based on which
* specific instance of a containing object exposed them (by way of a
* `composition` capability.)
*
* @param {DomainObject} domainObject the domain object for which
* context should be exposed
* @param {DomainObject} parentObject the domain object from which
* the wrapped object was retrieved
* *
* @constructor * @constructor
*/ */
function ContextualDomainObject(domainObject, parentObject) { function ContextualDomainObject(domainObject, parentObject) {
// Prototypally inherit from the domain object, and
// instantiate its context capability ahead of time.
var contextualObject = Object.create(domainObject), var contextualObject = Object.create(domainObject),
contextCapability = contextCapability =
new ContextCapability(parentObject, domainObject); new ContextCapability(parentObject, domainObject);
// Intercept requests for a context capability.
contextualObject.getCapability = function (name) { contextualObject.getCapability = function (name) {
return name === "context" ? return name === "context" ?
contextCapability : contextCapability :