"use strict";

exports.__esModule = true;
exports.default = void 0;

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

class Base {
  /**
   * Base constructor
   * @constructor Base
   * @param  {RBAC}     rbac     Instance of the RBAC
   * @param  {String}   name     Name of the grant
   * @param  {Function} cb       Callback function after add
   */
  constructor(rbac, name) {
    if (!rbac || !name) {
      throw new Error('One of parameters is undefined');
    }

    this.name = name;
    this.rbac = rbac;
  }
  /**
   * Add this to RBAC (storage)
   * @method Base#remove
   * @return {boolean}
   */


  add() {
    var _this = this;

    return _asyncToGenerator(function* () {
      const {
        rbac
      } = _this;
      return rbac.add(_this);
    })();
  }
  /**
   * Remove this from RBAC (storage)
   * @method Base#remove
   * @return {boolean}
   */


  remove() {
    var _this2 = this;

    return _asyncToGenerator(function* () {
      const {
        rbac
      } = _this2;
      return rbac.remove(_this2);
    })();
  }

}

exports.default = Base;
//# sourceMappingURL=Base.js.map