Created
September 17, 2014 12:14
-
-
Save eibrahim/d3ff33a6ad0c6035865a to your computer and use it in GitHub Desktop.
ArrayTransform EMber
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
App.ArrayTransform = DS.Transform.extend({ | |
serialize: function(jsonData) { | |
if (Em.typeOf(jsonData) === 'array') { | |
return jsonData; | |
} else { | |
return []; | |
} | |
}, | |
deserialize: function(externalData) { | |
switch (Em.typeOf(externalData)) { | |
case 'array': | |
return externalData; | |
case 'string': | |
return externalData.split(',').map(function(item) { | |
return jQuery.trim(item); | |
}); | |
default: | |
return []; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment