Skip to content

Instantly share code, notes, and snippets.

@lukes
Created March 23, 2015 02:30
Show Gist options
  • Save lukes/aecb5a1ccd7e4cd408ba to your computer and use it in GitHub Desktop.
Save lukes/aecb5a1ccd7e4cd408ba to your computer and use it in GitHub Desktop.
Ember DS.attr('object') -- (Allow declaring JSON as a valid property for an Ember model)
// save to app/models
import DS from "ember-data";
export default DS.Model.extend({
myProperty: DS.attr('object');
});
// save to app/transforms
// Note, only works with single-level-depth objects.
import DS from "ember-data";
import Ember from "ember";
export default DS.Transform.extend({
deserialize: function(serialized) {
return Ember.isBlank(serialized) ? {} : serialized;
},
serialize: function(deserialized) {
return Ember.isBlank(deserialized) ? {} : deserialized;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment