Created
May 25, 2010 19:15
-
-
Save keeto/413560 to your computer and use it in GitHub Desktop.
Class.mock Generic for MooTools
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.extend({ | |
mock: function(klass, options){ | |
options = options || {}; | |
klass = klass.prototype; | |
var proto = {}; | |
for (var i in klass) (function(key, value){ | |
proto[key] = options[key]; | |
if (proto[key]) return; | |
switch ($type(value)){ | |
case 'function': | |
proto[key] = function(){}; break; | |
case 'object': | |
case 'array': | |
proto[key] = $unlink(value); break; | |
default: | |
proto[key] = value; | |
} | |
})(i, klass[i]); | |
return new Class(proto); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment