0
1
Fork 0
hedera-web-mindshore/js/vn/lot-iface.js

92 lines
1.4 KiB
JavaScript

/**
* Holds a plain key-value javascript object and monitorizes changes over it.
*/
module.exports = new Class
({
Properties:
{
/**
* The internal object with the params, this is the lot internal object
* and should be used for read-only purposes.
*/
params:
{
type: Object
}
/**
* Shortcut for params property.
*/
,$:
{
type: Object
}
}
/**
* Gets a value from the set.
*
* @param {string} field The field name
* @return {*} The field value
*/
,get: function (field)
{
return this.params[field];
}
/**
* Sets a value on the set.
*
* @param {string} field The field name
* @param {*} value The new field value
*/
,set: function (field, value)
{
var params = {};
params[field] = value;
this.assign (params);
}
/**
* Returns an array with the set keys.
*
* @return {Array} The set keys
*/
,keys: function () {}
/**
* Emits the 'change' signal on the set.
*
* @param {Object} changes The changed params and its values
*/
,changed: function (changes)
{
this.emit ('change', changes);
}
/**
* Copies all values from another set.
*
* @param {Object} object The source object
*/
,assign: function () {}
/**
* Copies all values from another lot.
*
* @param {LotIface} lot The source lot
*/
,assignLot: function (lot)
{
this.assign (lot.params);
}
/**
* Resets all values.
*/
,reset: function ()
{
this.params = {};
}
});