Bandera.Group protocol (bandera v0.1.0)

Copy Markdown

Determines whether a given item (actor) belongs to a named group. Group names are compared as strings.

The built-in Map implementation reads a :groups list; binaries and integers belong to no group. Define the protocol for your own type to plug in custom group membership.

Summary

Types

t()

All the types that implement this protocol.

Functions

Returns true if item belongs to the group named group_name.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

in?(item, group_name)

@spec in?(t(), String.t()) :: boolean()

Returns true if item belongs to the group named group_name.

Examples

iex> Bandera.Group.in?(%{groups: [:beta, :staff]}, "beta")
true

iex> Bandera.Group.in?(%{groups: [:beta]}, "alpha")
false

iex> Bandera.Group.in?("plain-user", "beta")
false