EmberObjectUtils Class
Item Index
Methods
- addToHierarchy static
- belongsTo static
- hasMany static
- hasManyWithHierarchy static
- registerHierarchy static
Methods
addToHierarchy
-
hierarchy
-
type
-
classObj
-
level
Add an entry to the hierarchy. It takes care of updating meta also.
Parameters:
-
hierarchy
Object -
type
String -
classObj
Class -
level
Number
belongsTo
-
modelClass
-
[modelClassKey]
-
[defaultKey]
-
[mixin]
-
[mixinKey]
-
[defaultMixin]
-
[registry]
-
[idKey]
Creates a computed property for an object that when set with native js object will return an instances of a class.
The class is decided by the 1st param 'modelClass'. If it is not a class but an object and 'modelClassKey', the 2nd parameter is a string, then the 'modelClassKey' in the object is used as a key in 'modelClass' the object to get the class. 'defaultKey' the 3rd parameter is used as a default if object[modelClassKey] is not present.
Optionally can create the instance with mixin. A single mixin can be passed or a map of mixins as 4th parameter with key extracted from object using mixinKey (5th parameter) can be passed. 'defaultMixin' (6th parameter) is used when object[mixinKey] is not present.
Can pass a 7th argument. A registry of objects. If the object (identified by an idKey) is already present, reference to the object is returned. 8th argument is the idKey
Parameters:
-
modelClass
Class | Object -
[modelClassKey]
String optional -
[defaultKey]
String optional -
[mixin]
Mixin | Object optional -
[mixinKey]
String optional -
[defaultMixin]
String optional -
[registry]
Object optional -
[idKey]
String optional
Returns:
hasMany
-
modelClass
-
[modelClassKey]
-
[defaultKey]
-
[registry]
-
[idKey]
Creates a computed property for an array that when set with array of native js object will return an array of instances of a class.
The class is decided by the 1st param 'modelClass'. If it is not a class but an object and 'modelClassKey', the 2nd parameter is a string, then the 'modelClassKey' in the object is used as a key in 'modelClass' the object to get the class. 'defaultKey' the 3rd parameter is used as a default if object[modelClassKey] is not present.
Can pass a 4th argument. A registry of objects. If the object (identified by an idKey) is already present, reference to the object is returned. 5th argument is the idKey
Parameters:
-
modelClass
Class | Object -
[modelClassKey]
String optional -
[defaultKey]
String optional -
[registry]
Object optional -
[idKey]
String optional
Returns:
hasManyWithHierarchy
-
hasManyHierarchy
-
level
-
key
Creates a computed property which creates a class for every element in the set array based on hierarchy. The objects in the array can be of any level at or below the current level. An instance with the basic class is automatically wrapped around the objects at lower level.
Parameters:
-
hasManyHierarchy
ObjectAssumed to be already initialized by calling 'registerHierarchy'.
-
level
NumberLevel of the computed property.
-
key
StringKey used to get the key used in retrieving the class object in the classes map.
Returns:
registerHierarchy
-
hierarchy
Register a hierarchy. This will setup the meta of the hierarchy.
Parameters:
-
hierarchy
Object