From dc49873538a260f26bf503498926cc22ed7e0156 Mon Sep 17 00:00:00 2001 From: Ignacio Baixas Date: Mon, 26 Oct 2015 14:28:43 -0300 Subject: [PATCH] fix(Builder): fixes `mask` modifier being removed by mistake --- README.md | 6 +++--- src/module/builder.js | 1 + test/builder-spec.js | 13 +++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 34f036e..a50237c 100644 --- a/README.md +++ b/README.md @@ -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 }); ``` diff --git a/src/module/builder.js b/src/module/builder.js index 8c2ae5f..c1cec6c 100644 --- a/src/module/builder.js +++ b/src/module/builder.js @@ -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'] }, diff --git a/test/builder-spec.js b/test/builder-spec.js index 82b29d3..773e43a 100644 --- a/test/builder-spec.js +++ b/test/builder-spec.js @@ -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(); + }); + }); + });