Xema.Utils (xema v0.13.6) View Source
Some utilities for Xema.
Link to this section Summary
Functions
Returns whether the given key
exists in the given value
.
Returns the size of a list
or tuple
.
Converts the given string
to an existing atom. Returns nil
if the
atom does not exist.
Returns nil
if uri_1
and uri_2
are nil
.
Parses a URI when the other URI is nil
.
Merges URIs if both are not nil.
Link to this section Functions
Specs
Returns whether the given key
exists in the given value
.
Returns true if
value
is a map and containskey
as a key.value
is a keyword and containskey
as a key.value
is a list of tuples withkey
as the first element.
Example
iex> alias Xema.Utils
iex> Utils.has_key?(%{foo: 5}, :foo)
true
iex> Utils.has_key?([foo: 5], :foo)
true
iex> Utils.has_key?([{"foo", 5}], "foo")
true
Specs
Returns the size of a list
or tuple
.
Specs
Converts the given string
to an existing atom. Returns nil
if the
atom does not exist.
Examples
iex> import Xema.Utils
iex> to_existing_atom(:my_atom)
:my_atom
iex> to_existing_atom("my_atom")
:my_atom
iex> to_existing_atom("not_existing_atom")
nil
Specs
Returns nil
if uri_1
and uri_2
are nil
.
Parses a URI when the other URI is nil
.
Merges URIs if both are not nil.