Determine if the given ability should be granted for the current user.

@param  string  $ability
@param  array|mixed  $arguments
@return bool
185104
public function check($ability, $arguments = array())
    {
        if (! is_array($arguments)) {
            $arguments = array_slice(func_get_args(), 1);
        }

        try {
            $result = $this->raw($ability, $arguments);
        }
        catch (AuthorizationException $e) {
            return false;
        }

        return (bool) $result;
    }
1107266
public function authorizePermissionResource($resource, array $options = [])
    {
        $permissions = $this->resourcePermissionMap();
        $collection  = new Collection;
        foreach ($permissions as $method => $ability) {
            $collection->push(new Fluent([
                'ability' => $ability,
                'method'  => $method,
            ]));
        }

        $collection->groupBy('ability')->each(function ($permission, $ability) use ($resource, $options) {
            $this->middleware("can:{$resource}.{$ability}")
                 ->only($permission->pluck('method')->toArray());
        });
    }
409682
protected function syncAbilities($abilities, $options = ['forbidden' => false])
    {
        $abilityKeys = $this->getAbilityIds($abilities);
        $authority = $this->getAuthority();
        $relation = $authority->abilities();

        $this->newPivotQuery($relation)
             ->where('entity_type', $authority->getMorphClass())
             ->whereNotIn($this->getRelatedPivotKeyName($relation), $abilityKeys)
             ->where('forbidden', $options['forbidden'])
             ->delete();

        if ($options['forbidden']) {
            (new ForbidsAbilities($this->authority))->to($abilityKeys);
        } else {
            (new GivesAbilities($this->authority))->to($abilityKeys);
        }
    }
11415
final public function require_capability($capability, $user = null) {
        if (!is_int($user)) {
            $user = null;
        }
        $this->requiredcapabilities[] = array(
            'capability' => $capability,
            'user' => $user
        );
    }
710371
public function require_capability($capability, $userid = null, $doanything = true) {
        return $this->quizobj->require_capability($capability, $userid, $doanything);
    }
528586
protected function parseAbilityAndArguments($ability, $arguments)
    {
        if (is_string($ability)) {
            return [$ability, $arguments];
        }

        return [debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function'], $ability];
    }
1367904
public function has($ability)
    {
        $abilities = is_array($ability) ? $ability : func_get_args();

        foreach ($abilities as $ability) {
            if (! isset($this->abilities[$ability])) {
                return false;
            }
        }

        return true;
    }
1170737
protected function callBeforeCallbacks(User $user, $ability, array $arguments)
    {
        $arguments = array_merge(array($user, $ability), $arguments);

        foreach ($this->beforeCallbacks as $callback) {
            if (! is_null($result = call_user_func_array($callback, $arguments))) {
                return $result;
            }
        }
    }
1124918
private function runGateDefine(array $abilities_permissions)
    {
        foreach ($abilities_permissions as $ability => $policies) {
            $this->gate->define($ability, function ($user, $model = null) use ($ability, $policies) {
                $result = true;
                foreach ($policies as $restriction) {
                    if (is_array($restriction)) {
                        $policy = reset($restriction);
                        $operator = key($restriction);
                    } else {
                        $policy = $restriction;
                        $operator = 'and';
                    }

                    if (is_callable($policy)) {
                        $policy_method_return = call_user_func($policy, $user, $ability, $model);
                    } else {
                        list($class, $method) = explode('@', $policy);
                        $policy_method_return = app($class)->$method($user, $ability, $model); // should return boolean
                    }

                    if ($operator === 'or' || $operator === '||') {
                        $result = $result || $policy_method_return;
                    } else {
                        $result = $result && $policy_method_return;
                    }
                }

                return $result;
            });
        }
    }
279073
public static function gatekeeper($ability = null) {
    if (!isset(self::$currentUser)) {
      return false;
    }
    return self::$currentUser->gatekeeper($ability);
  }
749216
protected function resolveAuthCallback($user, $ability, array $arguments)
    {
        if (isset($arguments[0]) &&
            ! is_null($policy = $this->getPolicyFor($arguments[0])) &&
            $callback = $this->resolvePolicyCallback($user, $ability, $arguments, $policy)) {
            return $callback;
        }

        if (isset($this->stringCallbacks[$ability])) {
            [$class, $method] = Str::parseCallback($this->stringCallbacks[$ability]);

            if ($this->canBeCalledWithUser($user, $class, $method ?: '__invoke')) {
                return $this->abilities[$ability];
            }
        }

        if (isset($this->abilities[$ability]) &&
            $this->canBeCalledWithUser($user, $this->abilities[$ability])) {
            return $this->abilities[$ability];
        }

        return function () {
        };
    }
1086520
public function has_capability($capability, $userid = null, $doanything = true) {
        return has_capability($capability, $this->context, $userid, $doanything);
    }
1357828
public function define($ability, $callback)
    {
        if (is_callable($callback)) {
            $this->abilities[$ability] = $callback;
        } elseif (is_string($callback) && Str::contains($callback, '@')) {
            $this->abilities[$ability] = $this->buildAbilityCallback($callback);
        } else {
            throw new InvalidArgumentException("Callback must be a callable or a 'Class@method' string.");
        }

        return $this;
    }
525261
public function canRun($arguments = [])
    {
        $action = 'action' . ucfirst($this->getActiveAction());
        return $this->canCallMethod($action, $arguments ? $arguments : ($this->request ? $this->request->getParams() : []));
    }
1317746
def can(ability, add_headers=None):
    """"""
    client = ClientMixin(api_key=None)
    try:
        client.request('GET', endpoint='abilities/%s' % ability,
                       add_headers=add_headers)
        return True
    except Exception:
        pass
    return False
559810
protected function authorize($user, Gate $gate, string $ability, array $args): void
    {
        $can = $gate->forUser($user)->check($ability, $args);

        if (! $can) {
            throw new AuthorizationException(
                "You are not authorized to access {$this->definitionNode->name->value}"
            );
        }
    }
809324
public function recordGateCheck(?Authenticatable $user, $ability, $result, $arguments)
    {
        if (! Telescope::isRecording() || $this->shouldIgnore($ability)) {
            return;
        }

        $caller = $this->getCallerFromStackTrace();

        Telescope::recordGate(IncomingEntry::make([
            'ability' => $ability,
            'result' => $result ? 'allowed' : 'denied',
            'arguments' => $this->formatArguments($arguments),
            'file' => $caller['file'],
            'line' => $caller['line'],
        ]));

        return $result;
    }