matches method

bool matches(
  1. Permission type,
  2. String? resource
)

Check if this permission matches a resource

Implementation

bool matches(Permission type, String? resource) {
  if (permission != type && permission != Permission.fullAccess) {
    return false;
  }

  if (pattern == null || resource == null) {
    return true;
  }

  // Support wildcard patterns
  if (pattern!.endsWith('.*')) {
    final prefix = pattern!.substring(0, pattern!.length - 2);
    return resource.startsWith(prefix);
  }

  return pattern == resource;
}