Skip to content

Commit

Permalink
fix(Builder): fixes mask modifier being removed by mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
iobaixas committed Oct 26, 2015
1 parent 9f6e180 commit dc49873
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -896,9 +896,9 @@ Following the Angular conventions, attributes that start with a '$' symbol are c

```javascript
var Bike = restmod.model('/bikes').mix({
createdAt: {mask:'CU'}, // won't send this attribute on Create or Update
viewCount: {mask:'R'}, // won't load this attribute on Read (fetch)
opened: {mask:true}, // will ignore this attribute in relation to the API
createdAt: { ignore: 'CU' }, // won't send on Create or Update
viewCount: { ignore: 'R' }, // won't load on Read (fetch)
opened: { ignore: true }, // will ignore in every request and response
});
```

Expand Down
1 change: 1 addition & 0 deletions src/module/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ RMModule.factory('RMBuilder', ['$injector', 'inflector', '$log', 'RMUtils', func
var mappings = [
{ fun: 'attrDefault', sign: ['init'] },
{ fun: 'attrMask', sign: ['ignore'] },
{ fun: 'attrMask', sign: ['mask'] },
{ fun: 'attrMap', sign: ['map', 'force'] },
{ fun: 'attrDecoder', sign: ['decode', 'param', 'chain'] },
{ fun: 'attrEncoder', sign: ['encode', 'param', 'chain'] },
Expand Down
13 changes: 13 additions & 0 deletions test/builder-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,18 @@ describe('Restmod builder:', function() {
});
});

// Builtin object modifiers

describe('mask', function() {
it('should register a new mask ', function() {
var Bike = restmod.model(null, {
foo: { mask: 'CU' }
});

var bike = Bike.$build({ foo: 'bar' }).$encode('CU');
expect(bike.foo).toBeUndefined();
});
});

});

0 comments on commit dc49873

Please sign in to comment.