ExCellerate.Registry (excellerate v0.4.0)

Copy Markdown View Source

Provides functionality for creating custom function registries.

Registries allow you to define a set of custom functions (plugins) that extend the built-in capabilities of ExCellerate.

Usage

Define a registry module and use ExCellerate.Registry:

defmodule MyRegistry do
  use ExCellerate.Registry, plugins: [
    MyApp.Functions.Greet,
    MyApp.Functions.CustomMath
  ]
end

Then use it in ExCellerate.eval!/3 or call the generated eval!/2 directly:

# Using the registry in eval!/3
ExCellerate.eval!("greet(name)", %{"name" => "World"}, MyRegistry)

# Using the generated helper
MyRegistry.eval!("greet('World')")

Resolution Order

Functions are resolved at compile time in the following order:

  1. Registry plugins
  2. Default built-in functions

If a function name cannot be resolved, a compiler error is raised. Variables in the scope are only used for data access, not function calls.