fitz v0.1.1 Fitz.Map

Documentation for Fitz.Map.

Link to this section Summary

Functions

Map flatten. Converts atom keys to string

Examples

Map drop_nil. Removes key value pairs where the value is nil

Examples

Map flatten. Flattens a list of maps into one map

Examples

Map invert. Reverse the key with the value of each member of the map

Examples

Map key_from_value. Gets the key of a given value

Examples

Map reduce. Flattens a list of maps into one map

Examples

Map page_params. Converts github style pagination params into scrivener params

Examples

Map flatten. Converts string keys to atom

Examples

Link to this section Functions

Link to this function

atom_keys_to_string(map)

Map flatten. Converts atom keys to string

Examples

iex> params = %{per_page: 20, page: 3}
 %{per_page: 20, page: 3}
iex> Fitz.Map.atom_keys_to_string(params)
%{20 => "per_page", 3 => "page"}

Map drop_nil. Removes key value pairs where the value is nil

Examples

iex> params = %{"per_page" => 20, "page" => nil}
 %{"per_page" => 20, "page" => 3}
iex> Fitz.Map.page_params(params)
%{"per_page" => 20}

Map flatten. Flattens a list of maps into one map

Examples

iex> params = [%{"per_page" => 20}, %{"page" => nil}]
 [%{"per_page" => 20}, %{"page" => nil}]
iex> Fitz.Map.flatten(params)
%{"per_page" => 20, "page" => 3}

Map invert. Reverse the key with the value of each member of the map

Examples

iex> params = %{"per_page" => 20, "page" => 3}
 %{"per_page" => 20, "page" => 3}
iex> Fitz.Map.invert(params)
%{20 => "per_page", 3 => "page"}
Link to this function

key_from_value(map, value)

Map key_from_value. Gets the key of a given value

Examples

iex> params = %{"per_page" => 20, "page" => 3}
 %{"per_page" => 20, "page" => 3}
iex> Fitz.Map.key_from_value(params, 3)
"page"
Link to this function

page_params(pars)

Map reduce. Flattens a list of maps into one map

Examples

iex> params = [%{"per_page" => 20}, %{"page" => nil}]
 [%{"per_page" => 20}, %{"page" => nil}]
iex> Fitz.Map.reduce(params)
%{"per_page" => 20, "page" => 3}
Link to this function

scrub_get_params(conn, opts)

Map page_params. Converts github style pagination params into scrivener params

Examples

iex> params = %{"per_page" => 20, "page" => 3}
 %{"per_page" => 20, "page" => 3}
iex> Fitz.Map.page_params(params)
%{"page_size" => 20, "page" => 3}
Link to this function

string_keys_to_atom(map)

Map flatten. Converts string keys to atom

Examples

iex> params = %{20 => "per_page", 3 => "page"}
 %{20 => "per_page", 3 => "page"}
iex> Fitz.Map.string_keys_to_atom(params)
%{per_page: 20, page: 3}