Permalink
Browse files

change filter +spec updates

  • Loading branch information...
1 parent d14922c commit d85590066762a63d340dc604c4d7ec341c2e8629 @robrobbins robrobbins committed Mar 20, 2013
Showing with 34 additions and 4 deletions.
  1. +11 −2 build/debug/sudo-x.js
  2. +11 −2 extras/delegates/change/change.js
  3. +12 −0 extras/delegates/change/spec/change.spec.js
View
13 build/debug/sudo-x.js
@@ -1672,9 +1672,9 @@ sudo.delegates.Change.prototype = Object.create(sudo.Model.prototype);
// `param` {string} `val`
// `returns` {object} this
sudo.delegates.Change.prototype.addFilter = function addFilter(key, val) {
- this.get('filters')[key] = val;
+ this.data.filters[key] = val;
return this;
-},
+};
// ###filter
// Change records are delivered here and filtered, calling any matching
// methods specified in `this.get('filters').
@@ -1702,6 +1702,15 @@ sudo.delegates.Change.prototype.filter = function filter(change) {
return this.delegator[filters[name]].call(this.delegator, obj);
}
};
+// ###removeFilter
+// Remove an entry from this object's hash of filters
+//
+// `param` {string} `key`
+// `returns` {object} this
+sudo.delegates.Change.prototype.removeFilter = function removeFilter(key) {
+ delete this.data.filters[key];
+ return this;
+};
// `private`
sudo.delegates.Change.prototype.role = 'change';
//##Data Delegate
View
13 extras/delegates/change/change.js
@@ -20,9 +20,9 @@ sudo.delegates.Change.prototype = Object.create(sudo.Model.prototype);
// `param` {string} `val`
// `returns` {object} this
sudo.delegates.Change.prototype.addFilter = function addFilter(key, val) {
- this.get('filters')[key] = val;
+ this.data.filters[key] = val;
return this;
-},
+};
// ###filter
// Change records are delivered here and filtered, calling any matching
// methods specified in `this.get('filters').
@@ -50,5 +50,14 @@ sudo.delegates.Change.prototype.filter = function filter(change) {
return this.delegator[filters[name]].call(this.delegator, obj);
}
};
+// ###removeFilter
+// Remove an entry from this object's hash of filters
+//
+// `param` {string} `key`
+// `returns` {object} this
+sudo.delegates.Change.prototype.removeFilter = function removeFilter(key) {
+ delete this.data.filters[key];
+ return this;
+};
// `private`
sudo.delegates.Change.prototype.role = 'change';
View
12 extras/delegates/change/spec/change.spec.js
@@ -49,6 +49,18 @@ describe('Sudo Change Delegate', function() {
expect(spy).toHaveBeenCalled();
});
+ it('can add a filter', function() {
+ var del = view.delegate('change');
+ del.addFilter('isNaughty', 'acceptIt');
+ expect(del.get('filters').isNaughty).toBe('acceptIt');
+ });
+
+ it('can remove a filter', function() {
+ var del = view.delegate('change');
+ del.removeFilter('isNaughty');
+ expect(del.get('filters').isNaughty).toBeFalsy();
+ });
+
it('removes a delegate', function() {
var del = view.delegate('change');
view.removeDelegate('change');

0 comments on commit d855900

Please sign in to comment.