View Source Bonfire.Boundaries.Verbs (Bonfire v0.9.10-classic-beta.169)

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

Link to this function

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

View Source

Returns a changeset for the given verb and attributes.

Examples

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

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"}}

Link to this function

get(slug, all_verbs \\ verbs())

View Source

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
Link to this function

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

View Source

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"
Link to this function

get_id(slug, all_verbs \\ verbs())

View Source

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
Link to this function

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

View Source

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"
Link to this function

get_slug(id_or_name, all_verbs \\ verbs())

View Source

Retrieves a verb slug by its ID or name.

## Examples

iex> Bonfire.Boundaries.Verbs.get_slug("read_id")
:read
Link to this function

get_tuple(id_or_name, all_verbs \\ verbs())

View Source

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
Link to this function

ids(verbs, all_verbs \\ verbs())

View Source

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"]
Link to this function

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

View Source

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"]

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", ...]  

Returns the list of verb slugs.

Examples

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

Returns the list of verbs from the configuration.

Returns the count of verbs in the configuration.