specify v0.10.0 Specify.Options View Source
This struct represents the options you can pass
to a call of Specify.load/2
(or YourModule.load/1
).
Metaconfiguration
Besides making it nice and explicit to have the options listed here,
Specify.Options
has itself been defined using Specify.defconfig/2
,
which means that it (and thus what default options are passed on to to other Specify configurations)
can be configured in the same way.
Configuration structure documentation:
This configuration was made using the Specify
library.
It contains the following fields:
sources
A list of structures that implement the Specify.Provider
protocol, which will be used to fetch configuration from.
Later entries in the list take precedence over earlier entries.
Defaults always have the lowest precedence, and :explicit_values
always have the highest precedence.
A source can be:
- A struct. Example:
%Specify.Provider.SystemEnv{}
; - A module that has a
new/0
-method which returns a struct. Example:Specify.Provider.SystemEnv
; - A tuple, whose first argument is a module and second argument is a map of arguments. This will be turned into a full-blown struct at startup using
Kernel.struct/2
. Example:{Specify.Provider.SystemEnv, %{prefix: "CY", optional: true}}
; - A {module, function, arguments}-tuple, which will be called on startup. It should return a struct. Example:
{Specify.Provider.SystemEnv, :new, ["CY", [optional: true]]}
.
In all cases, the struct should implement the Specify.Provider
protocol (and this is enforced at startup).
Validated/parsed by calling Specify.Options.list_of_sources/1
.
Defaults to []
.
explicit_values
A list or map (or other enumerable) representing explicit values that are to be used instead of what can be found in the implicit sources stack.
Validated/parsed by calling Specify.Parsers.term/1
.
(Specified as :term
)
Defaults to []
.
missing_fields_error
The error to be raised if a missing field which is required has been encountered.
Validated/parsed by calling Specify.Parsers.term/1
.
(Specified as :term
)
Defaults to Specify.MissingRequiredFieldsError
.
parsing_error
The error to be raised if a field value could not properly be parsed.
Validated/parsed by calling Specify.Parsers.term/1
.
(Specified as :term
)
Defaults to Specify.ParsingError
.
explain
When set to true
, rather than returning the config struct,
a map is returned with every field-key containing a list of consecutive found values.
This is useful for debugging.
Validated/parsed by calling Specify.Parsers.boolean/1
.
(Specified as :boolean
)
Defaults to false
.
Metaconfiguration Gotcha's
Specify will only be able to find a source after it knows it exists. This means that it is impossible to define a different set of sources inside an external source.
For this special case, Specify will look at the current process' Process dictionary, falling back to the Application environment (also known as the Mix environment), and finally falling back to an empty list of sources (its default).
So, from lowest to highest precedence, option values are loaded in this order:
- Specify.Options default
- Application Environment
:specify
- Process Dictionary
:specify
field - Options passed to
Specify.defconfig
- Options passed to
YourModule.load
Requiring Specify to be configured in such an even more general way seems highly unlikely. If the current approach does turn out to not be good enough for your use-case, please open an issue on Specify's issue tracker.
Link to this section Summary
Functions
Loads, parses, and normalizes the configuration of Specify.Options
, based on the current source settings, returning the result as a struct.
Loads, parses and normalizes the configuration of Specify.Options
, using the provided explicit_values
(and falling back to values configured elsewhere)
Link to this section Functions
Loads, parses, and normalizes the configuration of Specify.Options
, based on the current source settings, returning the result as a struct.
For more information about the options this function supports, see
Specify.load/2
and Specify.Options
Loads, parses and normalizes the configuration of Specify.Options
, using the provided explicit_values
(and falling back to values configured elsewhere)
For more information about the options this function supports, see
Specify.load_explicit/3
and Specify.Options