specify v0.10.0 Specify.Provider.Process View Source

A Configuration Provider source based on the current process' Process Dictionary.

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

Link to this section Summary

Functions

By default, will try to use Process.get(YourModule) to fetch the source's configuration. A different key can be used by supplying a different key argument.

Link to this section Functions

Link to this function

new(key \\ nil, options \\ [])

View Source

By default, will try to use Process.get(YourModule) to fetch the source's configuration. A different key can be used by supplying a different key argument.

iex> Process.put(Pet, %{name: "Timmy", kind: :cat})
iex> Pet.load(sources: [Specify.Provider.Process.new(Pet)])
%Pet{name: "Timmy", kind: :cat}

iex> Process.put(:another_pet, %{name: "John", kind: :dog})
iex> Pet.load(sources: [Specify.Provider.Process.new(:another_pet)])
%Pet{name: "John", kind: :dog}