2018-09-25 16:28:26 +00:00
|
|
|
import { isArray, A } from '@ember/array';
|
2018-04-03 14:16:57 +00:00
|
|
|
import DS from 'ember-data';
|
|
|
|
/*
|
|
|
|
This should go inside a globally available place for all apps
|
|
|
|
|
|
|
|
DS.attr('array')
|
|
|
|
*/
|
|
|
|
export default DS.Transform.extend({
|
|
|
|
deserialize(value) {
|
2018-09-25 16:28:26 +00:00
|
|
|
if (isArray(value)) {
|
|
|
|
return A(value);
|
2018-04-03 14:16:57 +00:00
|
|
|
} else {
|
2018-09-25 16:28:26 +00:00
|
|
|
return A();
|
2018-04-03 14:16:57 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
serialize(value) {
|
2018-09-25 16:28:26 +00:00
|
|
|
if (isArray(value)) {
|
|
|
|
return A(value);
|
2018-04-03 14:16:57 +00:00
|
|
|
} else {
|
2018-09-25 16:28:26 +00:00
|
|
|
return A();
|
2018-04-03 14:16:57 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|