ExKeyCDN.Util (exkeycdn v0.0.1)
General purpose utility functions.
Link to this section Summary
Functions
Recursively convert a map of string keys into a map with atom keys. Intended to prepare responses for conversion into structs. Note that it converts any string into an atom, whether it existed or not.
Converts underscored values to hyphenated strings.
Converts hyphenated values to underscore delimited strings.
Link to this section Functions
atomize(map)
Specs
Recursively convert a map of string keys into a map with atom keys. Intended to prepare responses for conversion into structs. Note that it converts any string into an atom, whether it existed or not.
For unknown maps with unknown keys this is potentially dangerous, but should be fine when used with known ExKeyCDN endpoints.
Example
iex> ExKeyCDN.Util.atomize(%{"a" => 1, "b" => %{"c" => 2}})
%{a: 1, b: %{c: 2}}
get_limits(headers)
Specs
http()
Specs
http() :: ExKeyCDN.HTTP
hyphenate(value)
Specs
Converts underscored values to hyphenated strings.
Examples
iex> ExKeyCDN.Util.hyphenate("key_cdn")
"key-cdn"
iex> ExKeyCDN.Util.hyphenate(:key_cdn)
"key-cdn"
map_to_keywordlist(map)
Specs
map_to_struct(items, type, key)
Specs
successfull?(result)
Specs
underscorize(value)
Specs
Converts hyphenated values to underscore delimited strings.
Examples
iex> ExKeyCDN.Util.underscorize("key-cdn")
"key_cdn"
iex> ExKeyCDN.Util.underscorize(:"key-cdn")
"key_cdn"