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.clear = function () { var base = this base.keys.forEach(function(op){ base[op] = false }) }