Celixir.Program (Celixir v0.2.0)

Copy Markdown View Source

A compiled CEL program — parse once, evaluate many times.

Usage

{:ok, program} = Celixir.compile("x > 10 && y < 20")

{:ok, true} = Celixir.Program.eval(program, %{x: 15, y: 5})
{:ok, false} = Celixir.Program.eval(program, %{x: 5, y: 5})

Summary

Functions

Evaluates the program with the given bindings.

Evaluates the program, raising on error.

Creates a program from a parsed AST.

Types

t()

@type t() :: %Celixir.Program{ast: Celixir.AST.expr(), source: String.t()}

Functions

eval(program, bindings \\ %{})

Evaluates the program with the given bindings.

eval!(program, bindings \\ %{})

Evaluates the program, raising on error.

new(ast, source \\ "<compiled>")

Creates a program from a parsed AST.