Skip to content

Instantly share code, notes, and snippets.

@zeppelin
Created May 22, 2011 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeppelin/985937 to your computer and use it in GitHub Desktop.
Save zeppelin/985937 to your computer and use it in GitHub Desktop.
SproutCore: Monkey-patched SC.Record to get SC.Record.attr keys as an Array via class method
SC.Record.mixin({
recordAttributes: function() {
var obj = this.prototype;
var ret = [];
for(var key in obj) {
if ( SC.kindOf(obj[key], SC.RecordAttribute) )
ret.push(key);
}
return ret;
}
});
MyApp.MySCRecordSubclass = SC.Record.extend({
title: SC.Record.attr(String),
body: SC.Record.attr(String)
});
// MyApp.MySCRecordSubclass.recordAttributes()
// => ["title", "body"]
@zeppelin
Copy link
Author

man, it was so late in the evening when i did shit like that. updated!

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