Created
August 6, 2010 09:04
-
-
Save kentaromiura/511069 to your computer and use it in GitHub Desktop.
Private mootator for mooTools 1.2.4
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
Class.Mutators.Private = function(private) { | |
var Private = {}; | |
var me = this; | |
var imp = me.implement; | |
imp.apply(me, ['~', function() { | |
var uid = $uid(this); | |
private = null; | |
delete Private[uid]; | |
}]); | |
me.implement = function(key, value) { | |
if ($type(key) == 'string' && $type(value) == 'function') { | |
imp.apply(me, [key, function() { | |
var uid = $uid(this); | |
var priv = Private[uid] || (Private[uid] = $unlink(private)); | |
var args = $A(arguments); | |
args.push(priv); | |
var res = value.apply(this, args); | |
return res; | |
}]); | |
return me; | |
} | |
return imp.apply(me, arguments); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment