diff options
Diffstat (limited to 'src/thing/album.js')
-rw-r--r-- | src/thing/album.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/thing/album.js b/src/thing/album.js new file mode 100644 index 00000000..1915ab85 --- /dev/null +++ b/src/thing/album.js @@ -0,0 +1,43 @@ +import Thing from './thing.js'; + +import { + validateReference +} from './structures.js'; + +import { + showAggregate, + withAggregate +} from '../util/sugar.js'; + +export default class Album extends Thing { + #tracks; + + static updateError = { + tracks: Thing.extendPropertyError('tracks') + }; + + update(source) { + withAggregate(({ wrap, call, map }) => { + if (source.tracks) { + this.#tracks = map(source.tracks, validateReference('track'), { + errorClass: this.constructor.updateError.tracks + }); + } + }); + } +} + +const album = new Album(); + +try { + album.update({ + tracks: [ + 'lol', + 123, + 'track:oh-yeah', + 'group:what-am-i-doing-here' + ] + }); +} catch (error) { + showAggregate(error); +} |