From 08a087e99c6feb80ed27a456958c853d65898fb4 Mon Sep 17 00:00:00 2001 From: Richard Walker Date: Sat, 22 Mar 2014 18:02:43 +0100 Subject: [PATCH] Update docs to reflect changes in v4.0.0 Fix #11 --- README.md | 26 ++++++++++++-------------- example/example.js | 5 +---- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 9a0b2c7..590cacb 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,10 @@ var assignments = { 1: 'admin' } -admittance.load(permissions, assignments) +var user = admittance(permissions, assignments) -admittance(1).is('admin') //true -admittance(1).isnt('admin') //false +user(1).is('admin') //true +user(1).isnt('admin') //false ``` ### Full featured usage @@ -51,10 +51,7 @@ var permissionData = require('/some/example/permissions.json') //load in permissions from json permissions file. This could easily be loaded //from a db instead -admittance.load(permissionData, assignmentData) - -//alias admittance as user for readability -var user = admittance +var user = admittance(permissionData, assignmentData) //do permissions checks @@ -176,25 +173,26 @@ example: ## API -`admittance.load(permissionsobject, assignmentsobject)` +`admittance(permissionsobject, assignmentsobject)` -Load permissions and assignments from js objects. See the "Writing permissions" -and "Writing assignments" sections above +Load permissions and assignments from js objects and return an admittance instance. See the "Writing permissions" and "Writing assignments" sections above for how to write a permissions and assignments object -`admittance(id).is(permission)` +Admittance instance methods: (returned from admittance method) + +`is(permission)` Test if a given 'id' can be matched with given 'permission' -`admittance(id).isnt(permission)` +`isnt(permission)` Opposite of is. Equivalent of writing `!admittance(id).is(permission)` -`admittance(id).can(permission)` +`can(permission)` Alias for is -`admittance(id).cant(permission)` +`cant(permission)` Alias for isnt diff --git a/example/example.js b/example/example.js index cd8a5a8..ff3fb13 100644 --- a/example/example.js +++ b/example/example.js @@ -7,10 +7,7 @@ var permissionData = require('./example-permissions.json') //load in permissions from json permissions file. This could easily be loaded //from a db instead -admittance.load(permissionData, assignmentData) - -//alias admittance as user for readability -var user = admittance; +var user = admittance(permissionData, assignmentData) //do permissions checks