Created
March 23, 2015 02:30
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// save to app/models | |
import DS from "ember-data"; | |
export default DS.Model.extend({ | |
myProperty: DS.attr('object'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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