feat(xen-api): name record classes with types

This commit is contained in:
Julien Fontanet 2019-04-09 16:28:19 +02:00
parent 56961b55bd
commit 6c861bfd1f

View File

@ -34,7 +34,7 @@ const EVENT_TIMEOUT = 60
// =================================================================== // ===================================================================
const { defineProperties, freeze, keys: getKeys } = Object const { defineProperties, defineProperty, freeze, keys: getKeys } = Object
// ------------------------------------------------------------------- // -------------------------------------------------------------------
@ -1023,17 +1023,23 @@ export class Xapi extends EventEmitter {
const getObjectByRef = ref => this._objectsByRef[ref] const getObjectByRef = ref => this._objectsByRef[ref]
Record = function(ref, data) { Record = defineProperty(
defineProperties(this, { function(ref, data) {
$id: { value: data.uuid ?? ref }, defineProperties(this, {
$ref: { value: ref }, $id: { value: data.uuid ?? ref },
$xapi: { value: xapi }, $ref: { value: ref },
}) $xapi: { value: xapi },
for (let i = 0; i < nFields; ++i) { })
const field = fields[i] for (let i = 0; i < nFields; ++i) {
this[field] = data[field] const field = fields[i]
this[field] = data[field]
}
},
'name',
{
value: type,
} }
} )
const getters = { $pool: getPool } const getters = { $pool: getPool }
const props = { $type: type } const props = { $type: type }