Skip to content

Commit

Permalink
Issue balderdashy#221 implemented the *Controller syntax for defining…
Browse files Browse the repository at this point in the history
… a policy
  • Loading branch information
AmeenAhmed committed Mar 21, 2013
1 parent 4aa1d04 commit a6781c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/policies.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@ function runPolicy(controllerName, actionName, req, res, next) {
// Determine which policies apply directly to this request

// policy for this controller
var cPolicy = sails.config.policies[controllerName];

var cPolicy = sails.config.policies[controllerName];

// Get the controllerName and camelize it
var camelController = require('inflection').camelize(controllerName) + 'Controller';

// If a policy exists for the route don't bother looking for *Controller
// if it doesn't then check for
cPolicy = (!!cPolicy) ? cPolicy : sails.config.policies[camelController];


if (!_.isUndefined(cPolicy)) {
routePlan = cPolicy;

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"clean-css": "0.10.1",
"fs-watch-tree": "~0.2.2",
"jade": "0.28.0",
"inflection": "1.2.5",
"node-typescript": "0.1.3"
},
"devDependencies": {
Expand Down

0 comments on commit a6781c3

Please sign in to comment.