41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
var utils = require('../utils');
|
||
|
var common = require('./common');
|
||
|
var DataModificationBase = require('../base-messages/DataModificationBase');
|
||
|
|
||
|
module.exports = DataModificationMessage;
|
||
|
|
||
|
function DataModificationMessage(content, transport) {
|
||
|
DataModificationBase.call(this, content, transport);
|
||
|
}
|
||
|
|
||
|
require('util').inherits(DataModificationMessage, DataModificationBase);
|
||
|
|
||
|
DataModificationMessage.prototype.attribute = function (arg0, arg1, arg2) {
|
||
|
var name = arg0;
|
||
|
utils.validate.notEmptyString(name, 'attribute name');
|
||
|
utils.validate.attributeName(this._content.attributes, name);
|
||
|
|
||
|
if (arg1 === undefined) {
|
||
|
this._content.attributes.push({ name: name });
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
if (typeof arg1 === 'boolean') {
|
||
|
this._content.attributes.push({ name: name, successful: arg1 });
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
if (typeof arg1 === 'string') {
|
||
|
utils.validate.string(arg1, 'attribute old value');
|
||
|
utils.validate.string(arg2, 'attribute new value');
|
||
|
this._content.attributes.push({ name: name, old: arg1, new: arg2 });
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
throw new Error('Second argument is neither a boolean nor a string');
|
||
|
};
|
||
|
|
||
|
DataModificationMessage.prototype.log = common.log;
|