2023-03-01 09:39:41 -06:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2023-01-09 08:48:49 -08:00
|
|
|
import { Model } from 'miragejs';
|
2022-03-17 13:05:41 -05:00
|
|
|
|
|
|
|
|
export default Model.extend({
|
|
|
|
|
assignDefaults(defaultAttrs, attrs) {
|
|
|
|
|
Object.entries(defaultAttrs).map(([key, value]) => {
|
|
|
|
|
if (!attrs[key]) {
|
|
|
|
|
attrs[key] = value;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
defaultAttrs: () => ({
|
|
|
|
|
version: 1,
|
|
|
|
|
authorized_actions: ['no-op', 'read', 'update', 'delete'],
|
|
|
|
|
created_time: new Date(),
|
|
|
|
|
}),
|
|
|
|
|
save() {
|
|
|
|
|
this.assignDefaults(this.defaultAttrs(), this.attrs);
|
|
|
|
|
return Model.prototype.save.apply(this, arguments);
|
|
|
|
|
},
|
|
|
|
|
});
|