| 1 | dojo.provide("dojox.lang.aspect.counter"); |
| 2 | |
| 3 | (function(){ |
| 4 | var aop = dojox.lang.aspect; |
| 5 | |
| 6 | var Counter = function(){ |
| 7 | this.reset(); |
| 8 | }; |
| 9 | dojo.extend(Counter, { |
| 10 | before: function(/*arguments*/){ |
| 11 | ++this.calls; |
| 12 | }, |
| 13 | afterThrowing: function(/*excp*/){ |
| 14 | ++this.errors; |
| 15 | }, |
| 16 | reset: function(){ |
| 17 | this.calls = this.errors = 0; |
| 18 | } |
| 19 | }); |
| 20 | |
| 21 | aop.counter = function(){ |
| 22 | // summary: |
| 23 | // Returns an object, which can be used to count calls to methods. |
| 24 | |
| 25 | return new Counter; // Object |
| 26 | }; |
| 27 | })(); |