Serializable metadata for reconstructing closures from logs.
This struct captures the minimal compile-time environment information needed
to reconstruct a closure in a different runtime context. Unlike %Macro.Env{},
this struct only contains serializable data (atoms, lists, module names).
Fields
:imports- List of module names that were imported in the calling context:aliases- List of{short_alias, full_module}tuples:requires- List of module names that were required
Examples
iex> metadata = Runic.ClosureMetadata.from_caller(__ENV__)
%Runic.ClosureMetadata{
imports: [Enum, String],
aliases: [{MyAlias, My.Full.Module}],
requires: [Logger]
}
iex> env = Runic.ClosureMetadata.to_eval_env(metadata)
# Returns a %Macro.Env{} suitable for Code.eval_quoted/3
Summary
Functions
Extracts serializable metadata from a %Macro.Env{} struct.
Reconstructs a %Macro.Env{} suitable for evaluating quoted code.
Types
Functions
Extracts serializable metadata from a %Macro.Env{} struct.
Only captures module names and alias information - no functions, no compile-time state, no context that cannot be serialized.
Reconstructs a %Macro.Env{} suitable for evaluating quoted code.
This creates a minimal evaluation environment with the captured imports, aliases, and requires restored. Uses best-effort approach for imports - if a module isn't loaded, it's skipped.
Options
:base_env- Base environment to start from (defaults to current ENV)