kriszyp/compose — Issue #16: Decorate not working?
Author: loveencounterflow
Created: 2012-01-23 16:48:26+00:00
State: open

when trying to make decorators work, i produced the following code:

var log = console.log;

var Logged = function( method ){
return new Compose.Decorator( function( method_name ) {
log( "decorating " + method_name );
this[ method_name ] = function() {
log( "entering " + method_name );
R = method.apply( this, arguments );
log( "leaving " + method_name );
return R;
}
});
};

var C = Compose( {
'frob': Logged( function() { log( "performing" + frob ) } ) } );
c = new C()
c.frob()

which, i believe, keeps pretty close to the example given in the documentation. however, running the above gives

Error: Decorator not applied

is this a bug or is my own code buggy?