UNPKG

ember-legacy-class-transform

Version:
36 lines 980 B
import { dict } from '@glimmer/util'; import { PathReference } from './path'; import { VOLATILE_TAG } from '@glimmer/reference'; export default class RootReference { constructor(object) { this.chains = dict(); this.tag = VOLATILE_TAG; this.object = object; } value() { return this.object; } update(object) { this.object = object; // this.notify(); } get(prop) { let chains = this.chains; if (prop in chains) return chains[prop]; return chains[prop] = new PathReference(this, prop); } chainFor(prop) { let chains = this.chains; if (prop in chains) return chains[prop]; return null; } path(string) { return string.split('.').reduce((ref, part) => ref.get(part), this); } referenceFromParts(parts) { return parts.reduce((ref, part) => ref.get(part), this); } label() { return '[reference Root]'; } }