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,7 +1023,8 @@ export class Xapi extends EventEmitter {
const getObjectByRef = ref => this._objectsByRef[ref] const getObjectByRef = ref => this._objectsByRef[ref]
Record = function(ref, data) { Record = defineProperty(
function(ref, data) {
defineProperties(this, { defineProperties(this, {
$id: { value: data.uuid ?? ref }, $id: { value: data.uuid ?? ref },
$ref: { value: ref }, $ref: { value: ref },
@ -1033,7 +1034,12 @@ export class Xapi extends EventEmitter {
const field = fields[i] const field = fields[i]
this[field] = data[field] this[field] = data[field]
} }
},
'name',
{
value: type,
} }
)
const getters = { $pool: getPool } const getters = { $pool: getPool }
const props = { $type: type } const props = { $type: type }