Skip to content

Instantly share code, notes, and snippets.

@keeto
Created May 25, 2010 19:15
Show Gist options
  • Save keeto/413560 to your computer and use it in GitHub Desktop.
Save keeto/413560 to your computer and use it in GitHub Desktop.
Class.mock Generic for MooTools
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