feat: 🎸 initial credential-store modeling and mocking

This commit is contained in:
Randall Morey committed 2021-07-01 14:28:53 -04:00
1 parent 7413afb11d
commit 5519cf8557
18 files changed
+389

No files matched your search

@@ -0,0 +1,3 @@
import ApplicationSerializer from './application';
export default class CredentialStoreSerializer extends ApplicationSerializer {}
@@ -0,0 +1,24 @@
import JSONSerializer from '@ember-data/serializer/json';
export default class FragmentCredentialStoreAttributesSerializer extends JSONSerializer {
/**
* If an attribute is annotated as readOnly in the model, don't serialize it.
* Otherwise delegate to default attribute serializer.
*
* @override
* @method serializeAttribute
* @param {Snapshot} snapshot
* @param {Object} json
* @param {String} key
* @param {Object} attribute
*/
serializeAttribute(snapshot, json, key, attribute) {
const { type, options } = attribute;
let value = super.serializeAttribute(...arguments);
// Convert empty strings to null.
if (type === 'string' && json[key] === '') json[key] = null;
// Do not serialize read-only attributes.
if (options.readOnly) delete json[key];
return value;
}
}