Code coverage report for api/permission/Permission.js

Statements: 94.12% (16 / 17)      Branches: 80% (8 / 10)      Functions: 100% (4 / 4)      Lines: 94.12% (16 / 17)      Ignored: none     

All files » api/permission/ » Permission.js
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 721 1                                                       1 142 142   142 142     1                           20 13   7         2 2 2 2               1  
var FieldDBObject = require("./../FieldDBObject").FieldDBObject;
var Users = require("./../user/Users").Users;
 
/**
 * @class Permission
 * @name  Permission
 *
 * @description  The permission class specifies which user (User, Consultant or Bot)
 *        can do what action to what component in a given corpus.
 *        The specification needs three arguments: User, Verb, Object
 *
 *
 * @property {UserGeneric} user This is userid or username
 * @property {String} verb Verb is the action permitted:
 *        admin: corpus admin. admin can handle permission of other users
 *        read: can read
 *        addNew: can add/create new datum etc.
 *        edit: can edit/change the content of datum etc., including delete datum which is basically just changing datum states
 *        comment: can comment on datum etc.
 *        export: can export datum etc.
 * @property {String} directObject Object is sub-component of the corpus to which
 *            the action is directed:
 *        corpus: corpus and corpus details (description etc.)
 *        datum: datums in the corpus including their states
 *        session: sessions in the corpus
 *        datalist: datalists in the corpus
 *
 * @extends FieldDBObject
 */
var Permission = function Permission(options) {
  Eif (!this._fieldDBtype) {
    this._fieldDBtype = "Permission";
  }
  this.debug("Constructing Permission ", options);
  FieldDBObject.apply(this, arguments);
};
 
Permission.prototype = Object.create(FieldDBObject.prototype, /** @lends Permission.prototype */ {
  constructor: {
    value: Permission
  },
 
  // Internal models: used by the parse function
  INTERNAL_MODELS: {
    value: {
      users: Users
    }
  },
 
  length: {
    get: function() {
      if (this.users && this.users.length) {
        return this.users.length;
      }
      return 0;
    }
  },
  map: {
    get: function() {
      Eif (this.users && typeof this.users.map === "function") {
        var self = this;
        return function(callback) {
          return this.users.map.apply(self.users, [callback]);
        };
      } else {
        return undefined;
      }
    }
  }
});
exports.Permission = Permission;