class

Acl::Group

Inherits YAML::Serializable / Reference / Object

The Group is identified by a name and has permissions on a set of paths. It is used by Groups. NOTE: I did not used Hash().new(default) because it is annoying with passing the permissions in the constructor

Constructors

new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
Source
new(name : String, permissions : Hash(String, Acl::Perm), default : Acl::Perm = Acl::Perm::None)
guest = Acl::Group.new(name: "guest", default: Acl::Perm::None, permissions: {"/public" => Acl::Perm::Read})
user = Acl::Group.new(name: "user", default: Acl::Perm::Read, permissions: {"/protected" => Acl::Perm::None})
admin = Acl::Group.new(name: "admin", default: Acl::Perm::Write)
Source
new(name : String, permissions : Hash(Acl::Path, Acl::Perm) = Hash(Acl::Path, Acl::Perm).new, default : Acl::Perm = Acl::Perm::None)

Create a new named Group with optional parameters.

  • name is the name of the group (arbitrary String).
  • permissions is a hash of {Acl::Path.new("path") => `Perm`}.
  • default is the value used for every path not defined in the permissions.
guest = Acl::Group.new(name: "guest", default: Acl::Perm::None, permissions: {Acl::Path.new "/public" => Acl::Perm::Read})
user = Acl::Group.new(name: "user", default: Acl::Perm::Read, permissions: {Acl::Path.new "/protected" => Acl::Perm::None})
admin = Acl::Group.new(name: "admin", default: Acl::Perm::Write)
Source
new(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : YAML::Nodes::Node)
Source

Instance methods

[](path : String) : Acl::Perm

Same than Path[String]? but returns the defaut value if not found

Source
[]=(path : String, acl : Acl::Perm)

If a path exists, replace it with the given permission acl, else create it.

Source
[]?(path : String) : Acl::Perm | Nil

Tries to find the exact path with the permissions of this group.

Source
default
Source
default=(default : Acl::Perm)
Source
delete(path : String)

Remove the permissions associated to the path

Source
matching(path : String) : Acl::Perm

Same than Path[String]? but returns the defaut value if not found

Source
matching?(path : String) : Acl::Perm | Nil

Tries to match the path with the permissions of this group. If select every matching path and get the maximum permission among them.

Source
name
Source
name=(name : String)
Source
permissions
Source
permissions=(permissions : Hash(Acl::Path, Acl::Perm))
Source
permitted?(path : String, access : Acl::Perm) : Bool

Check if the group as the Acl::Perm required to have access to a given path.

  • path is the path that must be checked
  • access is the minimal Acl::Perm required for a given operation
guest = Acl::Group.new(name: "guest", default: Acl::Perm::None, permissions: {"/public" => Acl::Perm::Read})
guest.permitted "/public", Acl::Perm::Read  # => true
guest.permitted "/public", Acl::Perm::Write # => false
guest.permitted "/other", Acl::Perm::Read   # => false
Source