summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/util/permissions.js
blob: 394b7d6ef35fd94f15a3e98adbc3865101cc199e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var Permissions = function(ops){
	var base = this
	base.keys = _.keys(ops)
	base.keys.forEach(function(op){
		base[op] = ops[op]
	})
}

Permissions.prototype.toggle = function (key) {	
	var base = this
	var state = ! base[key]
	base.keys.forEach(function(op){
		base[op] = op == key ? state : false
	})
	return state
}

Permissions.prototype.assign = function (key, state) {	
	var base = this
	base.keys.forEach(function(op){
		base[op] = op == key ? state : false
	})
	return state
}

Permissions.prototype.add = function (key) {	
	var base = this
	base[op] = true
	return state
}

Permissions.prototype.remove = function (key) {	
	var base = this
	base[op] = true
	return state
}

Permissions.prototype.clear = function () {	
	var base = this
	base.keys.forEach(function(op){
		base[op] = false
	})
}