Fledex.Utils.Dsl (fledex v0.5.0)

View Source

Summary

Functions

This function takes an ast function block and adds an argument to the function. This is different from ast_add_argument_to_func_if_missing/1 that it does not expect there to be an arugment and therefore will raise an ArgumentError if it does find one.

This function takes an AST block of a function, checks whether the required parameter (trigger) is present, and if not will add one. This function is to decide on whether ast_create_anonymous_func/1 or ast_create_anonymous_func/2 should be called

This function takes an AST of a function body and wraps it into an anonymous function. It does expect that the arguments are handled as part of the function body, e.g. the function body should look something like this

This function is similar to ast_create_anonymous_func/1, except that no argument was specified in the block (because the user does not want to use it), even though the function should have one. The function will make sure to add the argument to the block before wrapping it into an anonymous function.

Functions

apply_effect(module, options, block)

ast_add_argument_to_func(block)

@spec ast_add_argument_to_func(any()) :: {:fn, [], [{:->, list(), list()}, ...]}

This function takes an ast function block and adds an argument to the function. This is different from ast_add_argument_to_func_if_missing/1 that it does not expect there to be an arugment and therefore will raise an ArgumentError if it does find one.

ast_add_argument_to_func_if_missing(block)

@spec ast_add_argument_to_func_if_missing(any()) ::
  {:fn, [], [{:->, list(), list()}, ...]}

This function takes an AST block of a function, checks whether the required parameter (trigger) is present, and if not will add one. This function is to decide on whether ast_create_anonymous_func/1 or ast_create_anonymous_func/2 should be called

NOTE: this function makes the assumption that a single argument is

  required.

ast_create_anonymous_func(block)

@spec ast_create_anonymous_func([{:->, list(), [[atom()] | any()]}]) ::
  {:fn, [], [{:->, list(), [[atom()] | any()]}]}

This function takes an AST of a function body and wraps it into an anonymous function. It does expect that the arguments are handled as part of the function body, e.g. the function body should look something like this:

  arg1 -> :ok
  arg1, arg2 -> :ok

ast_create_anonymous_func(args, block)

@spec ast_create_anonymous_func([atom()], any()) ::
  {:fn, [], [{:->, [], [[atom()] | any()]}]}

This function is similar to ast_create_anonymous_func/1, except that no argument was specified in the block (because the user does not want to use it), even though the function should have one. The function will make sure to add the argument to the block before wrapping it into an anonymous function.

ast_extract_configs(block)

@spec ast_extract_configs(Macro.t()) :: Macro.t()

configure_strip(strip_name, drivers, strip_options, config)

create_config(name, module, opts)

@spec create_config(atom(), atom(), keyword() | nil) ::
  Fledex.Animation.Manager.configs_t()

create_config(name, type, def_func, options)

@spec create_config(atom(), atom(), (map() -> Fledex.Leds.t()), keyword() | nil) ::
  Fledex.Animation.Manager.configs_t()

create_coordinator(name, options, function)

create_job(name, pattern, options, function)

init(opts)

@spec init(keyword()) :: :ok | {:ok, pid()}