Localize.PhoenixRuntime.Attrs (localize_phoenix_runtime v0.1.0-alpha.1)
View SourceProvides an interface to access and update Localize attributes
in sockets, or connections (hereinafter containers
).
Summary
Functions
Retrieves the value for key
from the container's attributes, or returns default
.
Retrieves the value for key
from the container's attributes.
Merges the given value into the container's attributes.
Returns true if the given key or attribute tuple represents a private attribute.
Replaces the container's attributes with the provided map.
Assigns value
to key
in the container's attributes.
Updates the container's attributes by applying the given function.
Updates the value assigned to key
in the container's attributes by applying the given function.
Types
@type attrs_fun() :: (map() -> Enumerable.t())
@type container() :: Phoenix.Socket.t() | Phoenix.LiveView.Socket.t() | Plug.Conn.t()
@type key() :: atom()
@type value() :: any()
Functions
Retrieves the value for key
from the container's attributes, or returns default
.
When no key is provided, returns the entire attributes map.
Retrieves the value for key
from the container's attributes.
Raises an error (with an optional custom message) if the key is not found.
Merges the given value into the container's attributes.
The value can be either a list of key-value pairs or a map.
Returns true if the given key or attribute tuple represents a private attribute.
A private attribute is one whose name starts with "__"
.
Replaces the container's attributes with the provided map.
Assigns value
to key
in the container's attributes.
Updates the container's attributes by applying the given function.
The function receives the current attributes map and must return an enumerable, which is then converted into a new map.
@spec update(container(), key(), update_fun()) :: container()
Updates the value assigned to key
in the container's attributes by applying the given function.