Filters are now all provided two additional pieces of information. These are 'target' and 'method'. Each type of filter needs to provide these in a different way to ensure backward api compatibility but its pretty easy to demonstrate each.
$.filters([{
id : "#exampleBeforeFilter",
target : "MyApp.Controllers.*",
before : "([a-z]*)",
advice : function(){
//the details are tacked on as an extra argument
var advisee = arguments[arguments.length - 1];
log.debug('Before %s.%s', advisee.target, advisee.method);
//logs "Before MyApp.Controllers.Foo.doit"
}
},{
id : "#exampleAroundFilter",
target : "MyApp.Views.*",
around : "(.*)",
advice : function(invocation){
log.debug('Around %s.%s', invocation.target, invocation.method);
//logs "Around MyApp.Views.Foo.renderit"
}
},{
id : "#exampleAfterFilter",
target : "MyApp.Models.*",
around : "(.*)",
advice : function(returnValue, target, method){
log.debug('After %s.%s', target, method);
//logs "After MyApp.Models.Bar.getit"
}
}]);
--
Christopher Thatcher