Skip to content

Instantly share code, notes, and snippets.

@StevenBlack
Created December 15, 2012 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StevenBlack/4297836 to your computer and use it in GitHub Desktop.
Save StevenBlack/4297836 to your computer and use it in GitHub Desktop.
Generative function to create a method and corresponding Pre- and Post- hook methods,
c={}
e="someMethod";
preProcessPost =function(c,e) {
var e1=e+"Pre",e2=e+"Process",e3=e+"Post";
c[e]=function(o){
if (this[e1](o)) {
this[e2](o);
this[e3](o);
}
};
c[e1]=function(o){return true;};
c[e2]=function(o){};
c[e3]=function(o){};
};
preProcessPost(c,e);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment