Skip to content

Instantly share code, notes, and snippets.

@kangax
Created October 18, 2008 00:59
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 kangax/17571 to your computer and use it in GitHub Desktop.
Save kangax/17571 to your computer and use it in GitHub Desktop.
Class.Methods.createAccessors = function() {
var accessors = $A(arguments), proto = this.prototype;
if (!accessors.length) {
accessors = Object.keys(proto).reject(function(prop) {
return Object.isFunction(proto[prop]);
});
};
accessors.each(function(prop){
proto['get' + prop.capitalize()] = function(){
return this[prop];
};
proto['set' + prop.capitalize()] = function(value){
this[prop] = value; return this;
};
});
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment