Permalink
Browse files

Merge pull request #5 from taskrabbit/addedAsDelegate

addedAsDelegate implemented in base.
  • Loading branch information...
2 parents 5f1dd28 + 8d1372d commit 13e89e22fd138d6ecaac08a28a731384d3988487 @robrobbins robrobbins committed Jun 17, 2013
Showing with 15 additions and 2 deletions.
  1. +1 −0 base/base.js
  2. +10 −0 base/spec/base.spec.js
  3. +2 −1 build/debug/sudo-x.js
  4. +2 −1 build/debug/sudo.js
View
1 base/base.js
@@ -19,6 +19,7 @@ sudo.Base = function() {
sudo.Base.prototype.addDelegate = function addDelegate(del) {
del.delegator = this;
this.delegates.push(del);
+ if('addedAsDelegate' in del) del.addedAsDelegate(this);
return this;
};
// ###base
View
10 base/spec/base.spec.js
@@ -6,6 +6,9 @@ describe('Sudo Base Object', function() {
d.burgle = function() {
return this.role;
};
+ d.addedAsDelegate = function() {
+ this.added = true;
+ };
});
it('is an instance of the Base class', function() {
@@ -25,6 +28,13 @@ describe('Sudo Base Object', function() {
expect(b.delegates.length).toBe(1);
});
+ it('calls addedAsDelegate if present', function() {
+ var spy = spyOn(d, 'addedAsDelegate').andCallThrough();
+ b.addDelegate(d);
+ expect(spy).toHaveBeenCalled();
+ expect(d.added).toBe(true);
+ });
+
it('can fetch a delegate by role', function() {
b.addDelegate(d);
expect(b.delegate('encyclopediaSalesman')).toBe(d);
View
3 build/debug/sudo-x.js
@@ -136,6 +136,7 @@ sudo.Base = function() {
sudo.Base.prototype.addDelegate = function addDelegate(del) {
del.delegator = this;
this.delegates.push(del);
+ if('addedAsDelegate' in del) del.addedAsDelegate(this);
return this;
};
// ###base
@@ -1815,7 +1816,7 @@ sudo.delegates.Data.prototype.removeFilter = function removeFilter(key) {
// `private`
sudo.delegates.Data.prototype.role = 'data';
-sudo.version = "0.9.4";
+sudo.version = "0.9.5";
window.sudo = sudo;
if(typeof window._ === "undefined") window._ = sudo;
}).call(this, this);
View
3 build/debug/sudo.js
@@ -136,6 +136,7 @@ sudo.Base = function() {
sudo.Base.prototype.addDelegate = function addDelegate(del) {
del.delegator = this;
this.delegates.push(del);
+ if('addedAsDelegate' in del) del.addedAsDelegate(this);
return this;
};
// ###base
@@ -827,7 +828,7 @@ sudo.extensions.observable = {
return this.deliverChangeRecords();
}
};
-sudo.version = "0.9.4";
+sudo.version = "0.9.5";
window.sudo = sudo;
if(typeof window._ === "undefined") window._ = sudo;
}).call(this, this);

0 comments on commit 13e89e2

Please sign in to comment.