lib/permissions/Cache.js
function CacheItem(permissionSchemaKey, actionsValue, permissions) {
    if (!actionsValue) {
        if (!utils.contains(permissionSchemaKey, TRIPLE_UNDERSCORE)) {
            throw new Error("Invalid permissions schema key.")
        }
        else {
            var key = permissionSchemaKey.split(TRIPLE_UNDERSCORE)[0];
            actionsValue = cache.get(key).actionsValue;
        }
    }

    /**
     * Getter for permissionSchemaKey
     * @returns {String}
     */
    this.getPermissionSchemaKey = function () {
        return permissionSchemaKey;
    };

    /**
     * Returns action value.
     * @param action {String} Action key
     * @returns {String}
     */
    this.getActionValue = function (action) {
        if (!action) {
            throw new Error('No arguments');
        }
        return actionsValue[action];
    };

    /**
     * Returns array of action values for the role
     * @param roleId {Number}
     * @returns {Array}
     */
    this.getRolePermissions = function (roleId) {
        if (!roleId) {
            throw new Error('No arguments');
        }
        return permissions[roleId];
    };

    /**
     * Getter of permissions
     * @returns {Object}
     */
    this.getPermissions = function () {
        return permissions;
    };

    /**
     * Getter of actions values.
     * @returns {Object}
     */
    this.getActionsValue = function () {
        return actionsValue;
    };

    this.permissions = permissions
    this.actionsValue = actionsValue
}
function CacheItem(permissionSchemaKey, actionsValue, permissions) {
    if (!actionsValue) {
        if (!utils.contains(permissionSchemaKey, TRIPLE_UNDERSCORE)) {
            throw new Error("Invalid permissions schema key.")
        }
        else {
            var key = permissionSchemaKey.split(TRIPLE_UNDERSCORE)[0];
            actionsValue = cache.get(key).actionsValue;
        }
    }

    /**
     * Getter for permissionSchemaKey
     * @returns {String}
     */
    this.getPermissionSchemaKey = function () {
        return permissionSchemaKey;
    };

    /**
     * Returns action value.
     * @param action {String} Action key
     * @returns {String}
     */
    this.getActionValue = function (action) {
        if (!action) {
            throw new Error('No arguments');
        }
        return actionsValue[action];
    };

    /**
     * Returns array of action values for the role
     * @param roleId {Number}
     * @returns {Array}
     */
    this.getRolePermissions = function (roleId) {
        if (!roleId) {
            throw new Error('No arguments');
        }
        return permissions[roleId];
    };

    /**
     * Getter of permissions
     * @returns {Object}
     */
    this.getPermissions = function () {
        return permissions;
    };

    /**
     * Getter of actions values.
     * @returns {Object}
     */
    this.getActionsValue = function () {
        return actionsValue;
    };

    this.permissions = permissions
    this.actionsValue = actionsValue
}
function CacheItem ( permissionSchemaKey , actionsValue , permissions ) { if ( ! actionsValue ) { if ( ! utils . contains ( permissionSchemaKey , TRIPLE_UNDERSCORE ) ) { throw new Error ( "Invalid permissions schema key." ) } else { var key = permissionSchemaKey . split ( TRIPLE_UNDERSCORE ) [ 0 ] ; actionsValue = cache . get ( key ) . actionsValue ; } } /**
     * Getter for permissionSchemaKey
     * @returns {String}
     */ this . getPermissionSchemaKey = function ( ) { return permissionSchemaKey ; } ; /**
     * Returns action value.
     * @param action {String} Action key
     * @returns {String}
     */ this . getActionValue = function ( action ) { if ( ! action ) { throw new Error ( 'No arguments' ) ; } return actionsValue [ action ] ; } ; /**
     * Returns array of action values for the role
     * @param roleId {Number}
     * @returns {Array}
     */ this . getRolePermissions = function ( roleId ) { if ( ! roleId ) { throw new Error ( 'No arguments' ) ; } return permissions [ roleId ] ; } ; /**
     * Getter of permissions
     * @returns {Object}
     */ this . getPermissions = function ( ) { return permissions ; } ; /**
     * Getter of actions values.
     * @returns {Object}
     */ this . getActionsValue = function ( ) { return actionsValue ; } ; this . permissions = permissions this . actionsValue = actionsValue }
Constructor to create cache item
@param permissionSchemaKey {String} unique key
@param actionsValue {Object} Object to Action key with value
@param permissions  {Object} Object having array of permissions to each role.
@constructor
Constructor to create cache item