cop.create('AddressLayer') .refineClass(Person, { address: function() { return 'Prof.-Dr.-Helmert Str.' }, toString: function() { var secret = 'foo' return cop.proceed() + ' (' + this.address() + ')'; }, });
cop.create('EmployerLayer') .refineClass(Person, { employer: function() { return 'HPI' }, toString: function() { alert(secret) return cop.proceed() + ' (' + this.employer() + ')'; }, });
Object.subclass('Person', { toString: function() { return 'Person(' + this.name + ')' }, })
reset
AddressLayer.flattened()
EmployerLayer.flattened()
COP great for development but   - Considerable performance impact   - When used only for development, layer has to be merged manually Merge definitions of layer into base layer automatically   - Add new properties and methods   - Replace properties and methods that do not proceed   - Merge methods of base layer into new methods when proceed is used