Distopy.Source protocol (distopy v0.1.0) View Source
Link to this section Summary
Source group callbacks
Returns the sub-source that defines the key key
. The function must return
a tuple with group_key
as an unique identifier of the sub-source in the
group, and the sub-source itself.
Returns a list of sub-sources identified by an unique "group" key.
Replaces the sub-source uniquely identified by group_key
. The given group
key is the one returned from get_sub_with_key/2
or list_source/1
.
Sets the current selected source identified by group_key
. A group of
sources shoud add new environment variables to the currently selected sub.
Returns wether the currently selected sub-source in group is the given
group_key
. The group key is the one returned from get_sub_with_key/2
or
list_source/1
.
Functions
Creates a new environment variable in the source. It will only be called if
the source returns true
from updatable?/1
.
Deletes the environment variable identified by key
in the source.
Returns the name of the source for display purposes.
Returns the reprensentation of a value for display purposes. Instead of
returning the raw binary value, it is possible to return text like
"hidden value"
, a parsed reprensentation of a JSON string, etc.
Get the value associated to the environment variables identified by key
.
It should raise if the variable is not defined.
Returns wether the given environment variable is defined in the source.
Returns the list of environment variable names defined in the source.
Represents a single key/value pair for display purposes.
Returns a displayable version of the given list of environment variables keys and values.
Returns wether the source has sub-sources, i.e. is a group of sources.
Returns wether the source can be modified by adding or remomving environment variables.
Link to this section Types
Specs
t() :: term()
Link to this section Source group callbacks
Specs
Returns the sub-source that defines the key key
. The function must return
a tuple with group_key
as an unique identifier of the sub-source in the
group, and the sub-source itself.
Do not mistake key
for group_key
. The former identifies an environment
variable name while the latter identifies a sub-source in a group.
Specs
Returns a list of sub-sources identified by an unique "group" key.
Specs
Replaces the sub-source uniquely identified by group_key
. The given group
key is the one returned from get_sub_with_key/2
or list_source/1
.
Specs
Sets the current selected source identified by group_key
. A group of
sources shoud add new environment variables to the currently selected sub.
Specs
Returns wether the currently selected sub-source in group is the given
group_key
. The group key is the one returned from get_sub_with_key/2
or
list_source/1
.
Link to this section Functions
Specs
Creates a new environment variable in the source. It will only be called if
the source returns true
from updatable?/1
.
Specs
Deletes the environment variable identified by key
in the source.
Specs
Returns the name of the source for display purposes.
Specs
Returns the reprensentation of a value for display purposes. Instead of
returning the raw binary value, it is possible to return text like
"hidden value"
, a parsed reprensentation of a JSON string, etc.
Specs
Get the value associated to the environment variables identified by key
.
It should raise if the variable is not defined.
Specs
Returns wether the given environment variable is defined in the source.
Specs
Returns the list of environment variable names defined in the source.
Specs
Represents a single key/value pair for display purposes.
See pairs_to_iodata/2
.
Specs
Returns a displayable version of the given list of environment variables keys and values.
The keys may or may not be defined in the source as the values are passed to the function.
Specs
Returns wether the source has sub-sources, i.e. is a group of sources.
Specs
Returns wether the source can be modified by adding or remomving environment variables.