Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable camelcase */
import Transform from 'ember-data/transform';
import {getOwner} from '@ember/application';
export default Transform.extend({
deserialize(serialized) {
let settings = {};
if (serialized) {
try {
settings = JSON.parse(serialized) || {};
} catch (e) {
settings = {};
}
}
let factory = getOwner(this).factoryFor('object:mailchimp-integration');
return factory.create(settings);
},
import { assert } from '@ember/debug';
import { get } from '@ember/object';
import Transform from 'ember-data/transform';
import JSONAPISerializer from 'ember-data/serializers/json-api';
/**
Transform for `MF.fragment` fragment attribute which delegates work to
the fragment type's serializer
@class FragmentTransform
@namespace MF
@extends DS.Transform
*/
const FragmentTransform = Transform.extend({
store: null,
type: null,
polymorphicTypeProp: null,
deserialize: function deserializeFragment(data) {
if (data == null) {
return null;
}
return this.deserializeSingle(data);
},
serialize: function serializeFragment(snapshot) {
if (!snapshot) {
return null;
}
import { isArray } from '@ember/array';
import Transform from 'ember-data/transform';
export default Transform.extend({
deserialize(value) {
return isArray(value) ? value : [];
},
serialize(value) {
return this.deserialize(value);
}
});
import Transform from 'ember-data/transform';
export default Transform.extend({
deserialize: function(serialized) {
return serialized;
},
serialize: function(deserialized) {
return deserialized;
}
});
import Transform from 'ember-data/transform';
export default Transform.extend({
deserialize(serialized) {
return serialized;
},
serialize(deserialized) {
return deserialized;
}
});
import NavigationItem from 'ghost-admin/models/navigation-item';
import Transform from 'ember-data/transform';
import {A as emberA, isArray as isEmberArray} from '@ember/array';
export default Transform.extend({
deserialize(serialized, options) {
let navItems, settingsArray;
try {
settingsArray = JSON.parse(serialized) || [];
} catch (e) {
settingsArray = [];
}
navItems = settingsArray.map((itemDetails) => {
itemDetails.isSecondary = options && options.isSecondary || false;
return NavigationItem.create(itemDetails);
});
return emberA(navItems);
},
import Transform from 'ember-data/transform';
import moment from 'moment';
export default Transform.extend({
deserialize(serialized) {
if (!serialized) {
return null;
}
return moment(serialized);
},
serialize(deserialized) {
if (!deserialized) {
return null;
}
return moment(deserialized).toISOString();
}
});
import Transform from 'ember-data/transform';
export default Transform.extend({
deserialize(value) {
return value / 2;
},
serialize(value) {
return value * 2 || null;
}
});
import { assert } from '@ember/debug';
import { getOwner } from '@ember/application';
import { makeArray } from '@ember/array';
import { get, computed } from '@ember/object';
import Transform from 'ember-data/transform';
/**
Transform for `MF.array` that transforms array data with the given transform
type.
@class ArrayTransform
@namespace MF
@extends DS.Transform
*/
const ArrayTransform = Transform.extend({
store: null,
type: null,
deserialize: function deserializeArray(data) {
if (data == null) {
return null;
}
let transform = get(this, 'transform');
data = makeArray(data);
if (!transform) {
return data;
}
import Transform from 'ember-data/transform';
import moment from 'moment';
export default Transform.extend({
deserialize(serialized) {
if (serialized) {
return moment(serialized);
}
return serialized;
},
serialize(deserialized) {
if (deserialized) {
return moment(deserialized).toDate();
}
return deserialized;
}
});