Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
flosse committed Jan 11, 2012
1 parent 6a7e732 commit a3d4775
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions README.markdown
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ mgr.addClass "User", User, ["name", "age"], ["name"]


# implement the ACL by overriding the method # implement the ACL by overriding the method
mgr.hasPermission = (action, next) -> mgr.hasPermission = (action, next) ->
if myACLRules(action) then next() if myACLRules(action) then next null, action
else next false else next (new joap.Error "You are not allowed to do that :-P"), 403
``` ```


#### Persistence #### Persistence
Expand All @@ -56,35 +56,35 @@ users = nStore.new './data/users.db', (err) ->
else else


# override # override
mgr.saveInstance = (clazz, id, obj, next) -> mgr.saveInstance = (action, obj, next) ->
if clazz is "User" if action.class is "User"
users.save id, obj, next users.save obj.id, obj, (err) -> next err, action
else else
next new Error "Storage for this class is not available" next (new Error "Storage for this class is not available"), a


# override # override
mgr.loadInstance = (clazz, id, next) -> mgr.loadInstance = (action, next) ->
if clazz is "User" if action.class is "User"
users.get id, next users.get id, (err, inst) -> next err, action, inst
else else
next new Error "Storage for this class is not available" next (new Error "Storage for this class is not available"), a


# override # override
mgr.queryInstances = (clazz, attrs, next) -> mgr.queryInstances = (a, next) ->
if clazz is "User" if a.class is "User"
(next = attrs; attrs = null) if typeof attrs is "function" if a.attributess?
if attrs? @users.find a.attributes, (err, res) -> next err, a, (id for id of res)
@users.find attrs, (err, res) -> next err, (id for id of res) else
else @users.all (err, res) -> next err, (id for id of res) @users.all (err, res) -> next err, a, (id for id of res)
else else
next new Error "Storage for this class is not available" next (new Error "Storage for this class is not available"), a


# override # override
mgr.deleteInstance = (clazz, id, next) -> mgr.deleteInstance = (a, next) ->
if clazz is "User" if a.class is "User"
users.remove id, next users.remove id, (err) -> next err, a
else else
next new Error "Storage for this class is not available" next (new Error "Storage for this class is not available"), a
``` ```


### Router ### Router
Expand Down Expand Up @@ -118,7 +118,7 @@ router.on "add", (action) ->
console.log "add iq received" console.log "add iq received"


if not classes[action.class]? if not classes[action.class]?
router.sendError "add", 404, "The class '#{action.class}' does not exists." router.sendError (new joap.Error "'#{action.class}' does't exists.", 404), action


# ... # ...


Expand Down

0 comments on commit a3d4775

Please sign in to comment.