Aug 16
Is it sad that the mentions of AOP these days relate to code like:
String.prototype.capitalize = String.prototype.capitalize.wrap(
function(proceed, eachWord) {
if (eachWord && this.include(” “)) {
// capitalize each word in the string
return this.split(” “).invoke(”capitalize”).join(” “);
} else {
// proceed using the original function
return proceed();
}
});“hello world”.capitalize() // “Hello world”
“hello world”.capitalize(true) // “Hello World”