Dart DocumentationprincipalPermission

Permission class

A permission containing a number of requirements.

class Permission extends Principled {

 // Shortcut to requirements.
 Set get needs => reqs;

 /**
  * Creates a new Permission for a single requirement value.
  */
 Permission(dynamic value) {
   add(value);
 }

 /**
  * Creates a new permission for the given list of requirement values.
  */
 Permission.s(List<dynamic> values) {
   addMany(values);
 }

 /**
  * Returns whether this permission can be accessed by the identity.
  */
 bool allows(Identity identity) => identity.contains(this);

}

Extends

Principled > Permission

Constructors

new Permission(value) #

Creates a new Permission for a single requirement value.

Permission(dynamic value) {
 add(value);
}

new Permission.s(List<Dynamic> values) #

Creates a new permission for the given list of requirement values.

Permission.s(List<dynamic> values) {
 addMany(values);
}

Properties

final Set needs #

Set get needs => reqs;

final Set reqs #

inherited from Principled
final Set reqs = new Set();

Methods

add(value) #

inherited from Principled

Adds a requirement value to this principled.

add(dynamic value) => reqs.add(new Requirement(value));

addMany(List<Dynamic> values) #

inherited from Principled

Adds many requirement values to this principled.

addMany(List<dynamic> values) => values.forEach(add);

bool allows(Identity identity) #

Returns whether this permission can be accessed by the identity.

bool allows(Identity identity) => identity.contains(this);

bool contains(Principled other) #

inherited from Principled

Returns whether the other principled is contained by this one.

bool contains(Principled other) => reqs.containsAll(other.reqs);