specify v0.4.2 Specify.Provider.SystemEnv View Source
A Configuration Provider source based on System.get_env/2
Values will be loaded based on #{prefix}_#{capitalized_field_name}
.
prefix
defaults to the capitalized name of the configuration specification module.
capitalized_field_name
is in CONSTANT_CASE
(all-caps, with underscores as word separators).
Examples
The following examples use the following specification for reference:
defmodule Elixir.Pet do
require Specify
Specify.defconfig do
@doc "The name of the pet"
field :name, :string
@doc "is it a dog or a cat?"
field :kind, :atom
end
end
iex> System.put_env("PET_NAME", "Timmy")
iex> System.put_env("PET_KIND", "cat")
iex> Pet.load(sources: [Specify.Provider.SystemEnv.new()])
%Pet{name: "Timmy", kind: :cat}
iex> Pet.load(sources: [Specify.Provider.SystemEnv.new("PET")])
%Pet{name: "Timmy", kind: :cat}
iex> System.put_env("SECOND_PET_NAME", "John")
iex> System.put_env("SECOND_PET_KIND", "dog")
iex> Pet.load(sources: [Specify.Provider.SystemEnv.new("SECOND_PET")])
%Pet{name: "John", kind: :dog}
Link to this section Summary
Link to this section Functions
Link to this function