Skip to content

Instantly share code, notes, and snippets.

@MrSchMax
Forked from pixelhandler/transforms.js
Last active August 29, 2015 14:17
Show Gist options
  • Save MrSchMax/9dab5bbdc00fea73c592 to your computer and use it in GitHub Desktop.
Save MrSchMax/9dab5bbdc00fea73c592 to your computer and use it in GitHub Desktop.
/*
DS.attr('object')
*/
App.ObjectTransform = DS.Transform.extend({
deserialize: function(value) {
if (!$.isPlainObject(value)) {
return {};
} else {
return value;
}
},
serialize: function(value) {
if (!$.isPlainObject(value)) {
return {};
} else {
return value;
}
}
});
/*
DS.attr('array')
*/
App.ArrayTransform = DS.Transform.extend({
deserialize: function(value) {
if (Ember.isArray(value)) {
return Em.A(value);
} else {
return Em.A();
}
},
serialize: function(value) {
if (Ember.isArray(value)) {
return Em.A(value);
} else {
return Em.A();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment