class Acl::Group
- Acl::Group
- Reference
- Object
Overview
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
Included Modules
- YAML::Serializable
Defined in:
lib/acl/group.crConstructors
- .new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
- .new(name : String, permissions : Hash(String, Acl::Perm), default : Acl::Perm = Acl::Perm::None)
-
.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.
Instance Method Summary
-
#[](path : String) : Acl::Perm
Same than Path[String]? but returns the defaut value if not found
-
#[]=(path : String, acl : Acl::Perm)
If a path exists, replace it with the given permission acl, else create it.
-
#[]?(path : String) : Acl::Perm | Nil
Tries to find the exact path with the permissions of this group.
- #default : Acl::Perm
- #default=(default : Acl::Perm)
-
#delete(path : String)
Remove the permissions associated to the path
-
#matching(path : String) : Acl::Perm
Same than Path[String]? but returns the defaut value if not found
-
#matching?(path : String) : Acl::Perm | Nil
Tries to match the path with the permissions of this group.
- #name : String
- #name=(name : String)
- #permissions : Hash(Acl::Path, Acl::Perm)
- #permissions=(permissions : Hash(Acl::Path, Acl::Perm))
-
#permitted?(path : String, access : Acl::Perm) : Bool
Check if the group as the
Acl::Perm
required to have access to a given path.
Constructor Detail
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)
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)
Instance Method Detail
Same than Path[String]? but returns the defaut value if not found
If a path exists, replace it with the given permission acl, else create it.
Tries to find the exact path with the permissions of this group.
Same than Path[String]? but returns the defaut value if not found
Tries to match the path with the permissions of this group. If select every matching path and get the maximum permission among them.
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