chore: 🤖 add support for grants on role model

This commit is contained in:
Randall Morey committed 2020-08-07 15:42:40 -04:00
1 parent 13f76659e4
commit ee6999251d
4 files changed
+102 -1

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import ApplicationSerializer from './application';
import { get } from '@ember/object';
export default class RoleSerializer extends ApplicationSerializer {
// =methods
/**
* If `adapterOptions.serializeGrants` is true, the serialization should
* include **only grants** and nothing else. Normally, grants are not
* serialized.
* @override
* @param {Snapshot} snapshot
* @return {object}
*/
serialize(snapshot) {
const serializeGrants = get(snapshot, 'adapterOptions.serializeGrants');
let serialized = super.serialize(...arguments);
if (serializeGrants) serialized = this.serializeWithGrants(snapshot);
return serialized;
}
serializeWithGrants(snapshot) {
return {
grants: snapshot.attr('grants')
};
}
}