Class pvr.controller.attributes.Attribute


Extends pvr.logging._LoggerMixin.
Represents an attribute of a pvr.controller._PropertyController object and maintains a binding with the associated attribute in the model layer.

Depending on the configuration of the associated pvr.controller.integration.Integration object, this class supports the following operations:

The pvr.controller._PropertyController class creates the pvr.controller.attributes.Attribute objects that are required for all standard attributes. The pvr.controller.attributes.Attribute objects that are common to all data types are created by the pvr.controller._PropertyController#createAttributes method. The pvr.controller.attributes.Attribute objects that are specific to a particular data type are created by the extended class's pvr.controller._PropertyController#createTypeMixinAttributes method. You can overload these methods in your custom controller classes to support additional attributes. Note that the total number of attributes can impact performance.


Defined in: <pvr\controller\attributes\Attribute.js>.

Constructor Summary

Constructor Attributes Constructor Name and Description
 

Method Summary

Method Attributes Method Name and Description
 
get()
Gets the attribute value.
 
Indicates whether the attribute value was explicitly set by an external data service or custom JavaScript.
 
set(pendingValue)
Sets the attribute value.
 
test(pendingValue)
Tests whether a particular value is valid for this attribute.
 
watch(callback)
Watches for changes to the attribute value and calls the specified callback function when changes occur.
Methods borrowed from class pvr.logging._LoggerMixin:
logDebug, logEntry, logError, logExit, logInfo, logWarning

Constructor Detail

pvr.controller.attributes.Attribute()

Method Detail

get()

Gets the attribute value.

If a change to the attribute value is pending, this method evaluates the change before returning the value.

Returns:
The attribute value.

isControlled()

Indicates whether the attribute value was explicitly set by an external data service or custom JavaScript.

Typically, the value for an attribute is obtained directly from the model. This value can be overridden when a view is rendered by a view layer setting but must never be overriden if it was explicitly set by an external data service or custom JavaScript.

Returns:
true if the attribute value was explicitly set by an external data service or custom JavaScript.

set(pendingValue)

Sets the attribute value.

The value is stored as a pending value until the current change set is processed. When the change set is processed, the value is converted and validated as required. If the pending value is invalid or must be coerced, an appropriate warning is logged. In some cases, the pending value might influence the value of other attributes. The resulting changes, if any, are incorporated in the controller's onChange event payload when the change set is processed.

Parameters:
pendingValue
The attribute value.

test(pendingValue)

Tests whether a particular value is valid for this attribute.

Before calling the pvr.controller.attributes.Attribute#set method, you can call this method to determine whether the value is valid.

Parameters:
pendingValue
The pending value.
Returns:
An error string if the value is invalid or null if it is valid.

watch(callback)

Watches for changes to the attribute value and calls the specified callback function when changes occur.

The callback function has the following signature, where "value" is the new attribute value and "attribute" is the affected pvr.controller.attributes.Attribute object.

function(value, attribute)

Parameters:
callback
The callback function.