Skip to content

Instantly share code, notes, and snippets.

@erichocean
Created February 2, 2011 05:49
Show Gist options
  • Save erichocean/807305 to your computer and use it in GitHub Desktop.
Save erichocean/807305 to your computer and use it in GitHub Desktop.
//
// 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.
@erichocean
Copy link
Author

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.

@erichocean
Copy link
Author

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment