Created
December 3, 2009 21:42
-
-
Save keeto/248563 to your computer and use it in GitHub Desktop.
Adds an afterImplement feature to Class
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
/* | |
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