Synopsis
Concise creation of delegate methods for your classes/objects
Usage
For objects
var objA = {
foo: function() {
return "a";
},
foo2: function() {
return "b";
}
};
var objB = {};
delega.delegateToObject(objB, objA, ['foo','foo2']);
expect(objB.foo()).to.be.equal("a");
expect(objB.foo2()).to.be.equal("b");
For classes
var objA = {
foo: function() {
return "a";
},
foo2: function() {
return "b";
}
};
var clazzB = function() {
this.a = objA;
};
delega.delegateToProperty(objB, 'a', ['foo', 'foo2']);
expect(new clazzB().foo()).to.be.equal("a");
expect(new clazzB().foo2()).to.be.equal("b");