specify v0.4.1 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).
iex> defmodule Elixir.Pet do iex> require Specify iex> Specify.defconfig do iex> @doc "The name of the pet" iex> field :name, :string iex> @doc "is it a dog or a cat?" iex> field :kind, :atom iex> end iex> end iex> System.put_env("PET_NAME", "Timmy") iex> System.put_env("PET_KIND", "cat") iex> Pet.load(sources: [Specify.Provider.SystemEnv.new("PET")]) %Pet{name: "Timmy", kind: :cat}
iex> System.put_env("SECOND_PET_NAME", "Bobby") iex> System.put_env("SECOND_PET_KIND", "cat") iex> Pet.load(sources: [Specify.Provider.SystemEnv.new("SECOND_PET")]) %Pet{name: "Bobby", kind: :cat}