Created
May 22, 2011 21:55
-
-
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
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
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"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
man, it was so late in the evening when i did shit like that. updated!