refactor: 💡 serialize scope_id by default
This commit is contained in:
21 files changed
+7
-266
No files matched your search
@@ -8,18 +8,6 @@ import { copy } from 'ember-copy';
|
||||
*/
|
||||
export default class ApplicationSerializer extends RESTSerializer {
|
||||
|
||||
// =attributes
|
||||
|
||||
attrs = {
|
||||
scope: { serialize: false }
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether or not to serialize the scope ID into scope_id.
|
||||
* @type {boolean}
|
||||
*/
|
||||
serializeScopeID = false;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
@@ -81,10 +69,11 @@ export default class ApplicationSerializer extends RESTSerializer {
|
||||
*/
|
||||
serialize(snapshot) {
|
||||
const serialized = super.serialize(...arguments);
|
||||
if (this.serializeScopeID) {
|
||||
const scope_id = snapshot?.attr('scope')?.attr('scope_id');
|
||||
if (scope_id) serialized.scope_id = scope_id;
|
||||
}
|
||||
// Delete `scope` field
|
||||
delete serialized.scope;
|
||||
// And serialize `scope_id`
|
||||
const scope_id = snapshot?.attr('scope')?.attr('scope_id');
|
||||
if (scope_id) serialized.scope_id = scope_id;
|
||||
return serialized;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user