const PermissionPlugin = {
  // eslint-disable-next-line no-unused-vars
  install(Vue, options) {
    Vue.prototype.$requirePermission = function(permission) {
      if (this.$store.getters.roles.indexOf('admin') > -1) {
        return true
      }

      var result = this.$store.getters.permissions.some(t => {
        return t.indexOf(permission) === 0
      })
      return result
    }
  }
}

export default PermissionPlugin
