Dymo v1.0.4 Dymo.Tag.Ns View Source
Describes a tag's namespace.
Link to this section Summary
Functions
We use cast/1
to transform and normalize external data into internal
data, eg when using Ecto.Changeset.cast
.
Callback implementation for Ecto.Type.embed_as/1
.
Callback implementation for Ecto.Type.equal?/2
.
This is a configurable parametter allowing to change the atom that will
be used for unspecified or nil
namespaces.
Link to this section Types
Specs
Specs
t() :: atom()
Link to this section Functions
Specs
cast(castable_t()) :: {:ok, t()} | :error
We use cast/1
to transform and normalize external data into internal
data, eg when using Ecto.Changeset.cast
.
Examples
Examples
iex> nil |> cast()
{:ok, root_namespace()}
iex> root_namespace() |> cast()
{:ok, root_namespace()}
iex> "blue" |> cast()
{:ok, :blue}
iex> :blue |> cast()
{:ok, :blue}
iex> "non existent atom" |> cast()
:error
iex> 3 |> cast()
:error
iex> [] |> cast()
:error
Specs
cast!(castable_t()) :: t()
Specs
The dump/1
function converts data into a format that can be stored in the
database using the type described by type/0
.
Examples
iex> nil |> dump()
{:ok, "root"}
iex> root_namespace() |> dump()
{:ok, "root"}
iex> :blue |> dump()
{:ok, "blue"}
iex> "blue" |> dump()
:error
iex> 3 |> dump()
:error
iex> [] |> dump()
:error
Callback implementation for Ecto.Type.embed_as/1
.
Callback implementation for Ecto.Type.equal?/2
.
Specs
We use load/1
to load data from the database into a normalized form,
very much like how cast/1
loads data from the outside world.
Examples
iex> nil |> load()
{:ok, root_namespace()}
iex> root_namespace() |> load()
{:ok, root_namespace()}
iex> "blue" |> load()
{:ok, :blue}
iex> :blue |> load()
{:ok, :blue}
iex> "non existent atom" |> load()
:error
iex> 3 |> load()
:error
iex> [] |> load()
:error
Specs
root_namespace() :: atom()
This is a configurable parametter allowing to change the atom that will
be used for unspecified or nil
namespaces.
Examples
iex> root_namespace()
:root
Specs
type() :: :string
The type/0
function describe what underlying type should be used for
storage.
Examples
iex> type()
:string