grimoire v0.0.2 Grimoire.Utilities.Itr
Shortcut for iterating over various maps. Includes an index, and excludes :meta
Link to this section Summary
Functions
Takes a map and callback function. Runs reduce. Removes the :meta field from iteration, but not from accumulator.
Link to this section Functions
Link to this function
columns(config, cb)
Link to this function
columns(config, k, cb)
Link to this function
columns(config, tablekey, cb, opts)
Link to this function
itr(config, m, cb, opts \\ %{})
Takes a map and callback function. Runs reduce. Removes the :meta field from iteration, but not from accumulator.
opts:
- iteratemeta = bool(false). whether to allow :_meta
- index = bool(false). whether to pass index into cb
- template = atom. Check permissions and hide if necessary.
- path = list of atoms. similar to put_in, runs cb at deeper part of m
- acc = set a custom accumulator. Defaults to map (at path)
Examples
iex> m = %{dogs: %{name: :string}}
iex> cb = fn ({tablekey, table}, acc) -> acc end
iex> itr(_, m, cb)
%{dogs: %{name: :string}}
iex> cb = fn ({tablekey, table, index}, acc) -> acc end
iex> itr(_, m, cb, %{index: true})
%{dogs: %{name: :string}}
iex> cb = fn ({k, v}, acc) -> Map.put(acc, :hello, "world") end
iex> m = %{a: %{b: %{c: %{d: "e"}}}}
iex> itr(_, m, cb, %{path: [:a, :b, :c]})
%{a: %{b: %{c: %{d: "e", hello: "world"}}}}
Link to this function
join_keys(arg)
Link to this function
joins(config, cb)
Link to this function
joins(config, k, cb)
Link to this function
joins(config, tkey, cb, opts)
Link to this function
normalize_join(arg)
Link to this function
set_trailing_comma(config, li, i)
Link to this function