Last active
August 29, 2015 14:22
-
-
Save ahume/3b5c98c97500eadcb05a to your computer and use it in GitHub Desktop.
withNoopToggle
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
define(function () { | |
return withNoopToggle; | |
function withNoopToggle() { | |
/** | |
* If toggle is false, do not execute named methods. | |
*/ | |
this.noopToggle = function (methods, toggle) { | |
methods.forEach(function (method) { | |
this.around(method, function (originalFunction) { | |
if (toggle) { | |
originalFunction(); | |
} | |
}) | |
}); | |
}; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment