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

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

        return $this->check($ability, $arguments);
    }
997820
protected function createGateUnauthorizedException($ability, $arguments, $message = null, $previousException = null)
    {
        $message = $message ?: __d('nova', 'This action is unauthorized.');

        return new HttpException(403, $message, $previousException);
    }
648271
public function authorize($ability, $arguments = array())
    {
        list($ability, $arguments) = $this->parseAbilityAndArguments($ability, $arguments);

        $gate = App::make('Nova\Auth\Access\GateInterface');

        return $this->authorizeAtGate($gate, $ability, $arguments);
    }
110349
public function revoke($ability) {
    if (in_array($ability, $this->abilities)) {
      return $this->abilities =
        array_values(array_diff($this->abilities, [$ability]));
    }
    return true;
  }
1279192
protected function resolvePolicyCallback($user, $ability, array $arguments)
    {
        return function () use ($user, $ability, $arguments) {
            $instance = $this->getPolicyFor($arguments[0]);

            if (method_exists($instance, 'before')) {
                // We will prepend the user and ability onto the arguments so that the before
                // callback can determine which ability is being called. Then we will call
                // into the policy before methods with the arguments and get the result.
                $beforeArguments = array_merge([$user, $ability], $arguments);

                $result = call_user_func_array([$instance, 'before'], $beforeArguments);

                // If we received a non-null result from the before method, we will return it
                // as the result of a check. This allows developers to override the checks
                // in the policy and return a result for all rules defined in the class.
                if (! is_null($result)) {
                    return $result;
                }
            }

            if (! is_callable([$instance, $ability])) {
                return false;
            }

            return call_user_func_array([$instance, $ability], array_merge([$user], $arguments));
        };
    }
1162780
public function any($abilities, $arguments = [])
    {
        return collect($abilities)->contains(function ($ability) use ($arguments) {
            return $this->check($ability, $arguments);
        });
    }
1305131
public function shouldRenderBasic(array $arguments) {
        if(isset($arguments['evenOnSamePage']) && $arguments['evenOnSamePage'] === true) {
            return $this->hasPermissions();
        } else {
            return $this->hasPermissions() && !$this->linksToCurrentPage($arguments);
        }
    }
644268
public function has_capability($capability, $userid = null, $doanything = true) {
        return $this->quizobj->has_capability($capability, $userid, $doanything);
    }
1144385
protected function resolvePolicyCallback($user, $ability, array $arguments, $policy)
    {
        if (! is_callable([$policy, $this->formatAbilityToMethod($ability)])) {
            return false;
        }

        return function () use ($user, $ability, $arguments, $policy) {
            // This callback will be responsible for calling the policy's before method and
            // running this policy method if necessary. This is used to when objects are
            // mapped to policy objects in the user's configurations or on this class.
            $result = $this->callPolicyBefore(
                $policy, $user, $ability, $arguments
            );

            // When we receive a non-null result from this before method, we will return it
            // as the "final" results. This will allow developers to override the checks
            // in this policy to return the result for all rules defined in the class.
            if (! is_null($result)) {
                return $result;
            }

            $method = $this->formatAbilityToMethod($ability);

            return $this->callPolicyMethod($policy, $method, $user, $arguments);
        };
    }
309543
public static function hasAccessInCapabilities(string $capability, string $userId): bool
    {
        $userCaps = static::fetchUserCapabilities($userId);
        if (in_array($capability, $userCaps)) {
            return true;
        }

        return false;
    }
812064
public function user_can( $capability ) {
		if ( ! ( $this->_post_type_obj instanceof \WP_Post_Type ) ) {
			return false;
		}

		return ! empty( $this->_post_type_obj->cap->$capability );
	}
111728
def user_has(ability, get_user=import_user):
    
    def wrapper(func):
        @wraps(func)
        def inner(*args, **kwargs):
            from .models import Ability
            desired_ability = Ability.query.filter_by(
                name=ability).first()
            user_abilities = []
            current_user = get_user()
            for role in current_user._roles:
                user_abilities += role.abilities
            if desired_ability in user_abilities:
                return func(*args, **kwargs)
            else:
                raise Forbidden("You do not have access")
        return inner
    return wrapper
473570
public function before($user, $ability)
    {
        if ($ability != 'view' && User::findOrFail($user->id)->superAdmin()) {
            return true;
        }
    }
537716
public function canAccept(self $arguments): bool
    {
        if ($this->values === null) {
            return true;
        }

        if ($this->equal($arguments)) {
            return true;
        }

        $values = $arguments->getValues();
        if ($values === null) {
            return false;
        }

        if (count($this->values) !== count($values)) {
            return false;
        }

        foreach ($values as $key => $actual) {
            $expected = $this->values[$key];

            if ($expected === $actual) {
                continue;
            }

            if ($expected instanceof MatcherAbstract) {
                if ($expected->match($actual)) {
                    continue;
                }
            }

            # If we couldn't find a match for this argument then give up
            return false;
        }

        return true;
    }
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;
    }
143920
protected function parseAbilityAndArguments($ability, $arguments)
    {
        if (is_string($ability) && strpos($ability, '\\') === false) {
            return [$ability, $arguments];
        }

        $method = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function'];

        return [$this->normalizeGuessedAbilityName($method), $ability];
    }
1122452
public function authorizeForUser($user, $ability, $arguments = array())
    {
        list($ability, $arguments) = $this->parseAbilityAndArguments($ability, $arguments);

        $gate = App::make('Nova\Auth\Access\GateInterface')->forUser($user);

        return $this->authorizeAtGate($gate, $ability, $arguments);
    }