Mnemonics v0.5.0 Mnemonics.Snap View Source
Snapshot of tables.
iex> snap = Mnemonics.Snap.new
%Mnemonics.Snap{versions: %{}, cache: %{}}
iex> snap = Mnemonics.Snap.snap snap, :examples, 1
%Mnemonics.Snap{versions: %{examples: 1}, cache: %{examples: %{}}}
iex> snap[:examples].version
1
iex> get_and_update_in snap[:examples].cache[1], fn value ->
iex> value = value || "example 1"
iex> {value, value}
iex> end
{"example 1", %Mnemonics.Snap{versions: %{examples: 1}, cache: %{examples: %{1 => "example 1"}}}}
Link to this section Summary
Link to this section Types
Link to this type
t()
View Source
t()
View Source
t() :: %Mnemonics.Snap{
cache: %{optional(atom()) => term()},
versions: %{optional(atom()) => pos_integer()}
}
t() :: %Mnemonics.Snap{
cache: %{optional(atom()) => term()},
versions: %{optional(atom()) => pos_integer()}
}
Link to this type
table_snap()
View Source
table_snap()
View Source
table_snap() :: %{version: pos_integer(), cache: term()}
table_snap() :: %{version: pos_integer(), cache: term()}
Link to this section Functions
Link to this function
new()
View Source
new()
View Source
new() :: t()
new() :: t()
Create a new snap.
iex> Mnemonics.Snap.new
%Mnemonics.Snap{versions: %{}, cache: %{}}
Link to this function
snap(snap, table_name, version, cache \\ %{})
View Source
snap(snap, table_name, version, cache \\ %{})
View Source
snap(t(), atom(), pos_integer(), term()) :: t()
snap(t(), atom(), pos_integer(), term()) :: t()
Snap the table with the version.
iex> snap = Mnemonics.Snap.new
iex> Mnemonics.Snap.snap snap, :examples, 1
%Mnemonics.Snap{versions: %{examples: 1}, cache: %{examples: %{}}}
iex> snap = Mnemonics.Snap.new
iex> put_in snap[:examples], %{version: 1}
%Mnemonics.Snap{versions: %{examples: 1}, cache: %{examples: %{}}}