matchesConditions method

bool matchesConditions(
  1. Object? subject
)

Whether subject satisfies this rule's conditions.

The asymmetry that matters

When the question is about a subject type rather than an instance — "can I update Articles at all?" — there is nothing to evaluate conditions against. A permitting rule answers yes, because there may well be an article you can update and refusing would hide the button for everyone. A forbidding rule answers no unless its conditions restrict nothing, because "you cannot update articles you did not write" must not be read as "you cannot update articles".

Implementation

bool matchesConditions(Object? subject) {
  final conditions = origin.conditions;
  if (conditions == null) return true;

  final value = subjectValue(subject);
  if (value == null || isSubjectType(value)) {
    if (!inverted) return true;
    return _compiledConditions(conditions).matchesEverything;
  }

  return _compiledConditions(conditions).matches(value);
}