2014-10-04 19:58:01 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
var
|
|
|
|
_ = require('_'),
|
|
|
|
|
|
|
|
Utils = require('Common/Utils');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*
|
|
|
|
* @param {string} sModelName
|
|
|
|
*/
|
|
|
|
function AbstractModel(sModelName)
|
|
|
|
{
|
|
|
|
this.sModelName = sModelName || '';
|
|
|
|
this.disposables = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {Array|Object} mInputValue
|
|
|
|
*/
|
|
|
|
AbstractModel.prototype.regDisposables = function(mInputValue)
|
|
|
|
{
|
|
|
|
if (Utils.isArray(mInputValue))
|
2014-10-04 19:58:01 +08:00
|
|
|
{
|
2016-06-30 08:02:45 +08:00
|
|
|
_.each(mInputValue, function(mValue) {
|
|
|
|
this.disposables.push(mValue);
|
|
|
|
}, this);
|
2014-10-04 19:58:01 +08:00
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
else if (mInputValue)
|
2014-10-04 19:58:01 +08:00
|
|
|
{
|
2016-06-30 08:02:45 +08:00
|
|
|
this.disposables.push(mInputValue);
|
|
|
|
}
|
2014-10-04 19:58:01 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
};
|
2014-10-04 19:58:01 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
AbstractModel.prototype.onDestroy = function()
|
|
|
|
{
|
|
|
|
Utils.disposeObject(this);
|
|
|
|
};
|
2014-10-04 19:58:01 +08:00
|
|
|
|
2016-06-30 08:02:45 +08:00
|
|
|
module.exports = AbstractModel;
|