Created
February 2, 2011 05:49
-
-
Save erichocean/807305 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// | |
// Define our model class. | |
// | |
MyApp.Task = SC.Object.extend({ | |
toJSON: function() { | |
var hash = {}, key, val; | |
for (key in this) { | |
if (!this.hasOwnProperty(key)) continue ; | |
val = this[key] ; | |
if (typeof val !== "function") hash[key] = val ; | |
} | |
return hash; | |
} | |
}); // gives us the "create" function. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hmm. This will include computed properties, but that only matters on SC.Record instances. In general, we just want the non-computed properties, so we can skip functions completely.