@param Person $person
@param string $ability

@return bool
434888
public function before(Person $person, $ability)
    {
        if ($person->isSuperUser()) {
            return true;
        }

        if (!$person->hasSite(Router::getActiveSite())) {
            return false;
        }
    }
999025
protected function callAfterCallbacks($user, $ability, array $arguments, $result)
    {
        foreach ($this->afterCallbacks as $after) {
            if (! $this->canBeCalledWithUser($user, $after)) {
                continue;
            }

            $afterResult = $after($user, $ability, $result, $arguments);

            $result = $result ?? $afterResult;
        }

        return $result;
    }
119892
public function addSubscriber($person)
    {
        if ($this->eql($person)) {
            return false;
        }

        if($this->subscribed($person)){
           return false;
        }

        $subscription = $this->subscriptions->findOrAddNew(array(
            'subscriber' => $person,
        ))->setData(array(
            'component' => $this->component,
            'author' => $person,
        ), AnDomain::ACCESS_PROTECTED);

        return $this->_mixer;
    }
156066
protected function createAbility($ability, $entity, $attributes)
    {
        return Models::ability()->createForModel($entity, $attributes + [
            'name' => $ability,
        ]);
    }
1294111
public function findOneByTerms(Competency $parent, Ability $ability)
    {
        $link = $this->findOneBy(['competency' => $parent, 'ability' => $ability]);

        if (!$link) {
            throw new \RuntimeException(
                "Competency {$parent->getId()} is not linked to ability {$ability->getId()}"
            );
        }

        return $link;
    }
585894
public function addBlocked($person)
    {
        //if A blocks B, then A must remove B as a follower
        //need to keep track of this since the mixin is a singleton
        $leader = $this->_mixer;

        if ($leader->eql($person)) {
            return false;
        }

        $person->removeFollower($leader);

        $leader->removeFollower($person);

        //just in case
        $person->removeRequester($leader);
        $leader->removeRequester($person);

        $edge = $this->getService('repos:actors.block')->findOrAddNew(array(
                'blocker' => $leader,
                'blocked' => $person,
            ));

        $edge->save();

        $this->resetStats(array($leader, $person));

        return $edge;
    }
123715
protected function callAfterCallbacks(User $user, $ability, array $arguments, $result)
    {
        $arguments = array_merge(array($user, $ability, $result), $arguments);

        foreach ($this->afterCallbacks as $callback) {
            call_user_func_array($callback, $arguments);
        }
    }
725242
public function can($ability, $arguments = [])
    {
        return app(Gate::class)->forUser($this)->check($ability, $arguments);
    }
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);
        };
    }
865670
public function can($ability, $arguments = array())
    {
        $gate = App::make('Nova\Auth\Access\GateInterface')->forUser($this);

        return $gate->check($ability, $arguments);
    }
119759
protected static function hasTypeAccessBelongs(array $capabilities, array $user, array $url): bool
    {
        $entity = static::getEntityFromUrl($url);

        $userGroups = static::getUserGroups($user);

        foreach ($capabilities as $capability) {
            if (!static::hasAccessInCapabilities($capability->getName(), $user['id'])) {
                continue;
            }

            // if url does not include an id and user has belongs to capability
            // access, to current module action, allow him access. (index action)
            if (empty($entity)) {
                return true;
            }

            // if url includes an id, check capability's field value from the entity
            // against current user id and if they match allow him access. (view, edit actions etc)
            $field = $capability->getField();

            foreach (array_keys($userGroups) as $id) {
                if ($entity->get($field) === $id) {
                    return true;
                }
            }
        }

        return false;
    }
82243
protected function callAuthCallback(User $user, $ability, array $arguments)
    {
        $callback = $this->resolveAuthCallback($user, $ability, $arguments);

        return call_user_func_array($callback, array_merge(array($user), $arguments));
    }
1162780
public function any($abilities, $arguments = [])
    {
        return collect($abilities)->contains(function ($ability) use ($arguments) {
            return $this->check($ability, $arguments);
        });
    }
710276
protected function resolveAuthCallback($user, $ability, array $arguments)
    {
        if ($this->firstArgumentCorrespondsToPolicy($arguments)) {
            return $this->resolvePolicyCallback($user, $ability, $arguments);
        } elseif (isset($this->abilities[$ability])) {
            return $this->abilities[$ability];
        } else {
            return function () {
                return false;
            };
        }
    }
917237
protected function isForbidden(Model $authority, $ability, $model = null)
    {
        return $this->getHasAbilityQuery(
            $authority, $ability, $model, $allowed = false
        )->exists();
    }
1352392
protected function isSpecificModelAbility(Model $ability)
    {
        return $ability->entity_type !== '*'
            && ! is_null($ability->entity_type)
            && ! is_null($ability->entity_id);
    }
473570
public function before($user, $ability)
    {
        if ($ability != 'view' && User::findOrFail($user->id)->superAdmin()) {
            return true;
        }
    }