nl_tokens: Build normalized hook - internal representation of policy mapping by performing a non - destructive parse of sails . config . policies
pl_tokens: <mask> ( ) { var mapping = { } ; _ . each ( sails . config . policies , function ( _policy , controllerId ) { // Accept `FooController` or `foo` // Case-insensitive controllerId = util . normalizeControllerId ( controllerId ) ; // Controller-level policy :: // Just map the policy to the controller directly if ( ! util . isDictionary ( _policy ) ) { mapping [ controllerId ] = policyHookDef . normalizePolicy ( _policy ) ; return ; } // Policy mapping contains a sub-object :: // So we need to dive in and build/normalize the policy mapping from here // Mapping each policy to each action for this controller mapping [ controllerId ] = { } ; _ . each ( _policy , function ( __policy , actionId ) { // Case-insensitive actionId = actionId . toLowerCase ( ) ; mapping [ controllerId ] [ actionId ] = policyHookDef . normalizePolicy ( __policy ) ; } ) ; } ) ; return mapping ; }