Methods
accept(visitor, opt_postorder)
Parameters:
Name | Type | Description |
---|---|---|
visitor |
Object | the visitor object |
opt_postorder |
boolean | whether to use postorder (true) or preorder (false) approach when traversing the tree of capsules |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
add(…var_args)
If this capsule represents the current context of execution, then its loop returned by the getDefaultParentLoop method is considered as a parent here.
If this capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its hook returned by the getDefaultParentHook method is considered as a parent here.
For each of the given capsules, the child hook or loop is determined like this:
If the given capsule represents the current context of execution, then its hook returned by the getDefaultChildHook method is considered as a child here.
If the given capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its loop returned by the getDefaultChildLoop method is considered as a child here.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Capsule |
<repeatable> |
child capsules whose hooks or loops would be added to their new parent (an array of capsules also accepted) |
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
addAt(at, …var_args)
If this capsule represents the current context of execution, then its loop returned by the getDefaultParentLoop method is considered as a parent here.
If this capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its hook returned by the getDefaultParentHook method is considered as a parent here.
For each of the given capsules, the child hook or loop is determined like this:
If the given capsule represents the current context of execution, then its hook returned by the getDefaultChildHook method is considered as a child here.
If the given capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its loop returned by the getDefaultChildLoop method is considered as a child here.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
at |
number | the index at which the child hooks or loops should be added to their new parent | |
var_args |
module:capsula.Capsule |
<repeatable> |
child capsules whose hooks or loops would be added to their new parent (an array of capsules also accepted) |
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
attach()
Attaches this capsule to be a part of the capsule that represents the current context of execution. Creates an implicit reference between the two capsules.
Recursively calls onAttach method (or operation) on this capsule and all its descendent capsules if they have that method.
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
clear()
If this capsule represents the current context of execution, then its loop returned by the getDefaultParentLoop method is considered as a parent here.
If this capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its hook returned by the getDefaultParentHook method is considered as a parent here.
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
detach()
Detaches this capsule as a part of the capsule that represents the current context of execution. Destroys an implicit reference between the two capsules. Detaching the capsule also means destroying all the wires and ties that exist between that capsule and all other sibling capsules (including itself) as well as between that capsule and its owner capsule.
Recursively calls onDetach method (or operation) on this capsule and all its descendent capsules if they have that method (this is to release resources and prevent memory leak).
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
(protected) detachAll()
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
getChildren() → {Array.<module:capsula.Capsule>}
If this capsule represents the current context of execution, then its loop returned by the getDefaultParentLoop method is considered as a parent here.
If this capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its hook returned by the getDefaultParentHook method is considered as a parent here.
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- Array.<module:capsula.Capsule>
(protected) getCurrentOperation() → {module:capsula.Operation}
- Since:
- 0.1.0
- Source:
Returns:
(protected) getData(id) → {Object}
Parameters:
Name | Type | Description |
---|---|---|
id |
string | the id of the data to return |
- Since:
- 0.1.0
- Deprecated:
- since version 0.2.0: instead of this.getData('x') write this.x.get()
- Source:
Throws:
- Type
- Error
Returns:
- Type
- Object
(protected) getDefaultChildHook()
By default this method works this way: when there is only one hook in this capsule, that hook is returned. When there is none or when there are more than one hook, an error is thrown.
The method is meant to be overridden in cases when capsule has more than one hook.
This method could only be called from the capsule's interior, i.e. only with "this".
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
getDefaultChildLoop()
By default this method works this way: when there is only one loop in this capsule, that loop is returned. When there is none or when there are more than one loop, an error is thrown.
The method is meant to be overridden in cases when capsule has more than one loop.
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
getDefaultParentHook()
By default this method works this way: when there is only one hook in this capsule, that hook is returned. When there is none or when there are more than one hook, an error is thrown.
The method is meant to be overridden in cases when capsule has more than one hook.
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
(protected) getDefaultParentLoop()
By default this method works this way: when there is only one loop in this capsule, that loop is returned. When there is none or when there are more than one loop, an error is thrown.
The method is meant to be overridden in cases when capsule has more than one loop.
This method could only be called from the capsule's interior, i.e. only with "this".
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
getFQName(opt_sepopt) → {string}
Returns the fully qualified name of this capsule, using the given separator if provided (if not, the :: is used by default).
The fully qualified name comprises the name of this capsule (in the context of its owner capsule), the name of the owner capsule of this capsule, and so on all the way up the capsule hierarchy.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
opt_sep |
string |
<optional> |
the separator to use to separate names in the returned fully qualified name |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- string
getHook(name) → {module:capsula.Hook}
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the name of the hook to return |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- module:capsula.Hook
getHooks() → {Array.<module:capsula.Hook>}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- Array.<module:capsula.Hook>
getId() → {number}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- number
getInput(name) → {module:capsula.Operation}
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the name of the input operation to return |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
getInputs() → {Array.<module:capsula.Input>}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- Array.<module:capsula.Input>
getLoop(name) → {module:capsula.Loop}
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the name of the loop to return |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- module:capsula.Loop
getLoops() → {Array.<module:capsula.Loop>}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- Array.<module:capsula.Loop>
getName() → {string}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- string
getOperation(name) → {module:capsula.Operation}
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the name of the operation to return |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
getOperations() → {Array.<module:capsula.Operation>}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- Array.<module:capsula.Operation>
getOutput(name) → {module:capsula.Operation}
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the name of the output operation to return |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
getOutputs() → {Array.<module:capsula.Output>}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- Array.<module:capsula.Output>
getParent()
If this capsule represents the current context of execution, then its hook returned by the getDefaultChildHook method is considered as a child here.
If this capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its loop returned by the getDefaultChildLoop method is considered as a child here.
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
getPart(name) → {module:capsula.Operation}
Parameters:
Name | Type | Description |
---|---|---|
name |
string | the name of the part to return |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
getParts() → {Array.<module:capsula.Capsule>}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- Array.<module:capsula.Capsule>
isAttached()
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
isParentOf(…var_args)
If this capsule represents the current context of execution, then its loop returned by the getDefaultParentLoop method is considered as a parent here.
If this capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its hook returned by the getDefaultParentHook method is considered as a parent here.
For each of the given capsules, the child hook or loop is determined like this:
If the given capsule represents the current context of execution, then its hook returned by the getDefaultChildHook method is considered as a child here.
If the given capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its loop returned by the getDefaultChildLoop method is considered as a child here.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Capsule |
<repeatable> |
child capsules whose hooks or loops would be checked (an array of capsules also accepted) |
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
remove(…var_args)
If this capsule represents the current context of execution, then its loop returned by the getDefaultParentLoop method is considered as a parent here.
If this capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its hook returned by the getDefaultParentHook method is considered as a parent here.
For each of the given capsules, the child hook or loop is determined like this:
If the given capsule represents the current context of execution, then its hook returned by the getDefaultChildHook method is considered as a child here.
If the given capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its loop returned by the getDefaultChildLoop method is considered as a child here.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Capsule |
<repeatable> |
child capsules whose hooks or loops would be removed from their old parent (an array of capsules also accepted) |
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
set(…var_args)
If this capsule represents the current context of execution, then its loop returned by the getDefaultParentLoop method is considered as a parent here.
If this capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its hook returned by the getDefaultParentHook method is considered as a parent here.
For each of the given capsules, the child hook or loop is determined like this:
If the given capsule represents the current context of execution, then its hook returned by the getDefaultChildHook method is considered as a child here.
If the given capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its loop returned by the getDefaultChildLoop method is considered as a child here.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Capsule |
<repeatable> |
child capsules whose hooks or loops would be set to their new parent (an array of capsules also accepted) |
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
(protected) setData(id, data)
Parameters:
Name | Type | Description |
---|---|---|
id |
string | the id under which to store the given data in the (protected) context of this capsule |
data |
Object | the data to store in the (protected) context of this capsule |
- Since:
- 0.1.0
- Deprecated:
- since version 0.2.0: instead of this.setData('x', 'hello!') write this.x = new Data('hello!')
- Source:
Throws:
- Type
- Error
setName(name)
Parameters:
Name | Type | Description |
---|---|---|
name |
string | a new name of this capsule |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
setParent(capsule)
If the given capsule represents the current context of execution, then its loop returned by the getDefaultParentLoop method is considered as a parent here.
If the given capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its hook returned by the getDefaultParentHook method is considered as a parent here.
If this capsule represents the current context of execution, then its hook returned by the getDefaultChildHook method is considered as a child here.
If this capsule represents a capsule which is a part of the capsule that represents the current context of execution, then its loop returned by the getDefaultChildLoop method is considered as a child here.
Parameters:
Name | Type | Description |
---|---|---|
capsule |
module:capsula.Capsule | a capsule whose select hook or loop would be set as a new parent to this capsule's select hook or loop. |
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
superior() → {Object}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- Object
Example
capsula.defCapsule({
base: BaseCapsule,
'+ myMethod': function(){
this.superior().myMethod.call(...); // calling a method that is just being overridden
}
});
untie(…var_args)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Capsule |
<repeatable> |
capsules to untie this capsule from (an array of capsules also accepted) |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
untieAll()
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
unwire(…var_args)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Capsule |
<repeatable> |
capsules to unwire this capsule from (an array of capsules also accepted) |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
unwireAll()
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error