Skip to content

Commit

Permalink
fix: New verb doesn't flush old ones for subject
Browse files Browse the repository at this point in the history
  • Loading branch information
mblarsen committed Oct 18, 2017
1 parent e137e41 commit 0143d8d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ class Acl {
* @param {Boolean} test=true
*/
rule(verbs, subject, test = true) {
const verbs_ = Array.isArray(verbs) ? verbs : [verbs]
const subject_ = this.subjectMapper(subject)
verbs.forEach(verb => this.rules.set(subject_, {[verb]: test}))
verbs_.forEach(verb => {
const rules = this.rules.get(subject_) || {}
rules[verb] = test
this.rules.set(subject_, rules)
})
return this
}

Expand Down

0 comments on commit 0143d8d

Please sign in to comment.