Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Created October 17, 2008 21:39
Show Gist options
  • Select an option

  • Save subtleGradient/17539 to your computer and use it in GitHub Desktop.

Select an option

Save subtleGradient/17539 to your computer and use it in GitHub Desktop.
Class.Mutators.Logs=function(self,methods){
$splat(methods).each(function(methodName){
var method = self[methodName];
self[methodName]=function(){
try{ console.log(Array.flatten([methodName, arguments]).join(',')); }catch(e){};
return method(arguments);
};
});
return self;
};
Class.Mutators.FiresEvents=function(self,methods){
$splat(methods).each(function(methodName){
var method = self[methodName];
self[methodName]=function(){
this.fireEvent(methodName,arguments);
return method(arguments);
};
});
return self;
};
MyClass = new Class({
FiresEvents:'test',
Logs:'test',
Implements:Events,
initialize: function(){},
test: function(){
return 'flarm';
}
});
myMyClass = new MyClass();
myMyClass.test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment