View Source Bonfire.Common.Utils (bonfire_umbrella v0.3.6-classic-beta.7)

Link to this section Summary

Functions

recursively merge maps or lists (into a map)

Returns a value, or a fallback if nil/false

Returns a value from a map, or a fallback if not present

Returns a value from a nested map, or a fallback if not present

Flattens a list by recursively flattening the head and tail of the list

Attempt geting a value out of a map by atom key, or try with string key, or return a fallback

Applies change_fn if the first parameter is not nil.

Append an item to a list if it is not nil

Helpers for calling hypothetical functions in other modules

Applies change_fn if the first parameter is an {:ok, val} tuple, else returns the value

conditionally update a map

Converts an enumerable to a list recursively Note: make sure that all keys are atoms, i.e. using input_to_atoms first

merge maps or lists (into a map)

Convert map atom keys to strings

Link to this section Functions

Link to this function

apply_error(error, args)

View Source
Link to this function

attr_get_id(attrs, field_name)

View Source
Link to this function

avatar_fallback(_ \\ nil)

View Source
Link to this function

contains?(string, substring)

View Source
Link to this function

current_account_and_or_user_ids(arg1)

View Source
Link to this function

current_user(current_user_or_socket_or_opts, recursing \\ false)

View Source
Link to this function

current_user_required!(context)

View Source
Link to this function

date_from_pointer(object)

View Source
Link to this function

debug_banner_with_trace(kind, exception, stacktrace)

View Source
Link to this function

debug_exception(msg, exception \\ nil, stacktrace \\ nil, kind \\ :error)

View Source
Link to this function

debug_log(msg, exception \\ nil, stacktrace \\ nil, kind \\ :error)

View Source

recursively merge maps or lists (into a map)

Link to this function

deep_merge_reduce(list_or_map)

View Source

Returns a value, or a fallback if nil/false

Link to this function

e(object, key, fallback)

View Source

Returns a value from a map, or a fallback if not present

Link to this function

e(object, key1, key2, fallback)

View Source

Returns a value from a nested map, or a fallback if not present

Link to this function

e(object, key1, key2, key3, fallback)

View Source
Link to this function

e(object, key1, key2, key3, key4, fallback)

View Source
Link to this function

e(object, key1, key2, key3, key4, key5, fallback)

View Source
Link to this function

e(object, key1, key2, key3, key4, key5, key6, fallback)

View Source
Link to this function

elem_or(verb, index, fallback)

View Source
Link to this function

filter_empty(val, fallback)

View Source

Flattens a list by recursively flattening the head and tail of the list

Link to this function

input_to_atoms(data, discard_unknown_keys \\ true, including_values \\ false)

View Source
Link to this function

magic_filter_empty(val, map, key, fallback \\ nil)

View Source
Link to this function

map_get(map, key, fallback)

View Source

Attempt geting a value out of a map by atom key, or try with string key, or return a fallback

Link to this function

map_key_replace(map, key, new_key, new_value \\ nil)

View Source

Rename a key in a map

Link to this function

map_key_replace_existing(map, key, new_key, new_value \\ nil)

View Source
Link to this function

map_new(data, fallback_key \\ :data)

View Source

Applies change_fn if the first parameter is not nil.

Link to this function

maybe_append(list, value)

View Source
@spec maybe_append([any()], any()) :: [any()]

Append an item to a list if it is not nil

Link to this function

maybe_apply(module, fun, args \\ [], fallback_fun \\ &apply_error/2)

View Source

Helpers for calling hypothetical functions in other modules

Link to this function

maybe_convert_ulids(list)

View Source
Link to this function

maybe_from_opts(opts, key, fallback \\ nil)

View Source
Link to this function

maybe_get(map, key, fallback \\ nil)

View Source
Link to this function

maybe_list(val, change_fn)

View Source
Link to this function

maybe_merge_to_struct(first, precedence)

View Source
Link to this function

maybe_ok_error(other, change_fn)

View Source
@spec maybe_ok_error(any(), any()) :: any()

Applies change_fn if the first parameter is an {:ok, val} tuple, else returns the value

Link to this function

maybe_put(map, key, value)

View Source

conditionally update a map

Link to this function

maybe_to_keyword_list(obj, recursive \\ false)

View Source

Converts an enumerable to a list recursively Note: make sure that all keys are atoms, i.e. using input_to_atoms first

Link to this function

maybe_to_map(obj, recursive \\ false)

View Source
Link to this function

maybe_to_snake_atom(string)

View Source
Link to this function

maybe_to_struct(obj, type \\ nil)

View Source
Link to this function

merge_as_map(left, right, conflict_fn \\ nil)

View Source

merge maps or lists (into a map)

Link to this function

merge_structs_as_map(target, merge)

View Source
Link to this function

module_to_human_readable(module)

View Source
Link to this function

nested_structs_to_maps(struct)

View Source
Link to this function

ok_unwrap(val, fallback \\ nil)

View Source
Link to this function

put_new_in(map, list, val)

View Source
Link to this function

replace_error(other, value)

View Source
Link to this function

replace_nil(other, value)

View Source
Link to this function

stringify_keys(map, recursive \\ false)

View Source

Convert map atom keys to strings

Link to this function

struct_from_map(a_map, list)

View Source
Link to this function

to_options(user_or_socket_or_opts)

View Source