grain.ex 409 Bytes
Newer Older
Jens-Christian Fischer's avatar
Jens-Christian Fischer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
defmodule Grengine.Grain do

  alias Grengine.{Grain, Parameter}


  def start_link() do
    Agent.start_link(fn -> %{}  end)
  end

  def get(grain, key) do
    Agent.get(grain, fn map -> map[key] end)
  end

  def set(grain, key, value) do
    Agent.update(grain, &Map.put(&1, key, value))
  end


  def get_values(grain) do
    Agent.get(grain, &(&1))
  end


  def to_string(grain) do
    "{}"
  end

end