View Source Camarero.Tapas behaviour (camarero v1.0.3)

This behaviour is high-level abstraction of the container begind handlers.

Aññ handlers are supposed to implement this behaviour. The simplest way is to use Camarero.Plato in the handler module; that will inject the default boilerlate using %{binary() => any()} map as a container behind.

Default implementation uses Camarero.Tapas as low-level container implementation.

Summary

Types

t()

Camarero.Tapas allows anything implementing Access behaviour as a container

Callbacks

Deletes the key-value pair for the key specified from the container

Retrieves from the container and returns the value for the key specified

Returns the empty container to be used to store the data.

Sets the value for the key specified (intended to be used from the application)

Types

@type t() :: Access.t()

Camarero.Tapas allows anything implementing Access behaviour as a container

Callbacks

@callback tapas_delete(bag :: t(), key :: binary() | atom()) :: {any(), t()}

Deletes the key-value pair for the key specified from the container

@callback tapas_get(bag :: t(), key :: binary() | atom()) :: {:ok, any()} | :error

Retrieves from the container and returns the value for the key specified

@callback tapas_into() :: t()

Returns the empty container to be used to store the data.

The returned term must implement Access behaviour since it’d be used from CR[U]D operations (tapas_get/2, tapas_put/3, and tapas_delete/2).

Link to this callback

tapas_put(bag, key, value)

View Source
@callback tapas_put(bag :: t(), key :: binary() | atom(), value :: any()) :: {any(), t()}

Sets the value for the key specified (intended to be used from the application)