Skip to content

Instantly share code, notes, and snippets.

@wsk3201
Created April 1, 2014 06:51
Show Gist options
  • Select an option

  • Save wsk3201/9909053 to your computer and use it in GitHub Desktop.

Select an option

Save wsk3201/9909053 to your computer and use it in GitHub Desktop.
Object.defineProperty(instance, key, {
get: function () {
return opts.data[key];
},
set: function (val) {
if (Model.allProperties[key].key === true && opts.data[key] != null) {
return;
}
if (!setInstanceProperty(key, val)) {
return;
}
if (opts.autoSave) {
saveInstanceProperty(key, val);
} else if (opts.changes.indexOf(key) === -1) {
opts.changes.push(key);
}
},
enumerable: true
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment