Skip to content

Instantly share code, notes, and snippets.

@jcready
Last active December 10, 2015 07:18
Show Gist options
  • Save jcready/4399669 to your computer and use it in GitHub Desktop.
Save jcready/4399669 to your computer and use it in GitHub Desktop.
function Model(props) {
var obj = { 'props': props };
for (o in obj.props) {
if (obj.props.hasOwnProperty(o)) {
this[o] = new Function("value", "if (!arguments.length) return typeof this.props['" + o.toString() +
"'] == 'function' ? this.props['" + o.toString() + "'].call(this) : this.props['" + o.toString() + "'];" +
"this.props['" + o.toString() + "'] = (typeof value == 'function' ? value.call(this) : value); return this")
}
}
return obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment