MavuUtils (MavuUtils v0.1.11) View Source
An opinionated set of utility functions used by other (upcoming) packages under mavuio/*
Link to this section Summary
Functions
tests if value is "blank"
tests if value is one of several falsy values.
applies a value when piped value is_empty ( as defined by present?/1 )
applies a value when piped value is nil
simple pipeable logger.
macro to only apply a function within a pipe if a condition equals to true.
tests if value is "non-blank"
tries to convert any value to integer
tests if value is one of several truthy values and not false?/1
Link to this section Functions
tests if value is "blank"
tests if value is one of several falsy values.
applies a value when piped value is_empty ( as defined by present?/1 )
##Example:
taxrate_item =
taxrates[taxkey]
|> if_empty(%{tax: "0", net: "0", gross: "0"})
|> taxrate_item_append(create_taxrate_stats_entry_for_item(item))
applies a value when piped value is nil
##Example:
get_max_order_id() |> if_nil(1000)
simple pipeable logger.
setting a loglevel is mandatory
order |> MavuUtils.log("trying to finish order #{order.id}", :info) |> finish_order()
macro to only apply a function within a pipe if a condition equals to true.
the conditional gets passed to true?/1 first
##Example:
|> pipe_when(
item[:taxrate],
update_in([:taxrates], &update_taxrate_stats(&1, item))
)
tests if value is "non-blank"
tries to convert any value to integer
returns integer on success, nil on failure
tests if value is one of several truthy values and not false?/1