Skip to content

Instantly share code, notes, and snippets.

@keeto
Created December 3, 2009 21:42
Show Gist options
  • Save keeto/248563 to your computer and use it in GitHub Desktop.
Save keeto/248563 to your computer and use it in GitHub Desktop.
Adds an afterImplement feature to Class
/*
Script: Class.AfterImplement.js
Adds an afterImplement feature to Class: a function
fired after every implemented item.
License & Copyright:
Copyright 2009, Mark Obcena <keetology.com>
MIT-Style License
*/
(function(){
var oldImplement = Class.prototype.implement;
Class.prototype.implement = function(key, value){
if ($type(key) == 'object'){
for (var p in key) oldImplement.call(this, p, key[p]);
return this;
}
oldImplement.call(this, key, value);
(this.afterImplement || function(){}).apply(this, key, value);
return this;
};
Class.implement = function(obj, key, value){
return Class.prototype.implement.call(obj, key, value);
};
Class.Mutators.AfterImplement = function(fn){
if (fn instanceof Function) this.afterImplement = fn;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment