DynamicModule v0.1.7 DynamicModule View Source

Generate a new module based on AST.

Link to this section Summary

Functions

Generate .beam and .ex files based on

Generate module name based on app, prefix and name. The postfix is optional

Normalize name to atom

Link to this section Functions

Link to this macro

gen(mod_name, preamble, contents, opts \\ []) View Source (macro)

Generate .beam and .ex files based on:

  • mod_name - the module name
  • preamble - the module attibutes and directives in AST, e.g. use GenServer, require Logger, etc
  • contents - the module body in AST

Options

  • :doc - the documents to the module. Defaults to false
  • :path - the path for generated .ex files. Defaults to ""
  • :create - a boolean value indicates whether to create .beam file. Defaults to true
Link to this function

gen_module_name(app, prefix, name, postfix \\ "") View Source
gen_module_name(atom(), String.t(), String.t(), String.t()) :: String.t()

Generate module name based on app, prefix and name. The postfix is optional.

Examples

iex> DynamicModule.gen_module_name(:app, "Prefix", "name")
"App.Prefix.Name"

iex> DynamicModule.gen_module_name(:app, "Prefix", "name", "Postfix")
"App.Prefix.Name.Postfix"
Link to this function

normalize_name(name) View Source
normalize_name(String.t() | atom()) :: atom()

Normalize name to atom.

Examples

iex> DynamicModule.normalize_name("a")
:a

iex> DynamicModule.normalize_name(:abc)
:abc