View Source Bonfire.Boundaries.Verbs (Bonfire v0.9.11-social-beta.6)

Verbs represent actions users can perform, such as reading a post or replying to a message. Each verb has a unique ID and are defined in configuration.

The corresponding Ecto schema is Bonfire.Data.AccessControl.Verb which is defined in a seperate repo.

Summary

Functions

Returns a changeset for the given verb and attributes.

Creates a new verb with the given attributes.

Retrieves a verb by its slug or ID.

Retrieves verb details by its ID or name, raising an error if not found.

Retrieves a verb ID by its slug.

Retrieves a verb ID by its slug or ID, raising an error if not found.

Retrieves a verb slug by its ID or name.

Retrieves a verb tuple by its ID or name.

Retrieves the IDs of the given verbs.

Lists the verbs from the specified source and key.

Returns a debug list of verbs by comparing the database and code.

Returns the list of verb slugs.

Returns the list of verbs from the configuration.

Returns the count of verbs in the configuration.

Functions

changeset(verb \\ %Verb{}, attrs)

Returns a changeset for the given verb and attributes.

Examples

iex> Bonfire.Boundaries.Verbs.changeset(%{verb: :new_verb, description: "A new verb"})

create(attrs)

Creates a new verb with the given attributes.

Examples

Bonfire.Boundaries.Verbs.create(%{verb: :new_verb, description: "A new verb"}) {:ok, %Verb{id: "new_verb_id", verb: :new_verb, description: "A new verb"}}

get(slug, all_verbs \\ verbs())

Retrieves a verb by its slug or ID.

Examples

iex> Bonfire.Boundaries.Verbs.get(:read)
%{id: "read_id", verb: :read}

iex> Bonfire.Boundaries.Verbs.get("read_id")
%{id: "read_id", verb: :read}

iex> Bonfire.Boundaries.Verbs.get("non_existent")
nil

get!(id_or_name, all_verbs \\ verbs())

Retrieves verb details by its ID or name, raising an error if not found.

Examples

iex> Bonfire.Boundaries.Verbs.get!("read")
%{id: "some_id", verb: :read}  # Example output

iex> Bonfire.Boundaries.Verbs.get!("non_existent_id")
** (RuntimeError) Missing default verb: "non_existent_id"

get_id(slug, all_verbs \\ verbs())

Retrieves a verb ID by its slug.

Examples

iex> Bonfire.Boundaries.Verbs.get_id(:read)
"read_id"

iex> Bonfire.Boundaries.Verbs.get_id("read")
"read_id"

iex> Bonfire.Boundaries.Verbs.get_id("non_existent")
nil

get_id!(slug, all_verbs \\ verbs())

Retrieves a verb ID by its slug or ID, raising an error if not found.

iex> Bonfire.Boundaries.Verbs.get_id!(:read)
"read_id"

iex> Bonfire.Boundaries.Verbs.get_id!("non_existent")
** (RuntimeError) Missing default verb: "non_existent"

get_slug(id_or_name, all_verbs \\ verbs())

Retrieves a verb slug by its ID or name.

## Examples

iex> Bonfire.Boundaries.Verbs.get_slug("read_id")
:read

get_tuple(id_or_name, all_verbs \\ verbs())

Retrieves a verb tuple by its ID or name.

Examples

iex> Bonfire.Boundaries.Verbs.get_tuple("read_id")
{:read, %{id: "read_id", verb: :read}}

iex> Bonfire.Boundaries.Verbs.get_tuple("non_existent")
nil

ids(verbs, all_verbs \\ verbs())

Retrieves the IDs of the given verbs.

iex> Bonfire.Boundaries.Verbs.ids([:read, :write])
["read_id", "write_id"]

iex> Bonfire.Boundaries.Verbs.ids(:read)
["read_id"]

list(from \\ :db, key \\ :verb)

Lists the verbs from the specified source and key.

Examples

iex> Bonfire.Boundaries.Verbs.list(:db, :verb)
%{read: %Verb{id: "read_id", verb: :read}, write: %Verb{id: "write_id", verb: :write}}

iex> Bonfire.Boundaries.Verbs.list(:instance, :id)
["read_id", "write_id"]

list_verbs_debug()

Returns a debug list of verbs by comparing the database and code.

Examples

> Bonfire.Boundaries.Verbs.list_verbs_debug()
# Example output:
[ok: :read, error: "Code and DB have differing IDs for the same verb", ...]  

slugs()

Returns the list of verb slugs.

Examples

iex> Bonfire.Boundaries.Verbs.slugs()
[:read, :write]

verbs()

Returns the list of verbs from the configuration.

verbs_count()

Returns the count of verbs in the configuration.