SC.ValueEvaluator (sc v1.0.2)
View SourceHandles compilation and evaluation of SCXML value expressions using Predicator v3.0.
This module extends beyond boolean conditions to evaluate actual values from expressions, supporting nested property access, assignments, and complex data model operations.
Key features:
- Value evaluation (not just boolean conditions)
- Nested property access (user.profile.name)
- Location path validation for assignments
- Mixed access patterns (dot and bracket notation)
- Type-safe value extraction
Examples
# Value evaluation
{:ok, compiled} = SC.ValueEvaluator.compile_expression("user.profile.name")
{:ok, value} = SC.ValueEvaluator.evaluate_value(compiled, context)
# => {:ok, "John Doe"}
# Location path validation for assignments
{:ok, path} = SC.ValueEvaluator.resolve_location("user.settings.theme", context)
# => {:ok, ["user", "settings", "theme"]}
Summary
Functions
Assign a value to a location in the data model using the resolved path.
Compile a value expression string into predicator instructions.
Evaluate an expression and assign its result to a location in the data model.
Evaluate a compiled expression to extract its value (not just boolean result).
Resolve a location path from a string expression only (without context validation).
Resolve a location path for assignment operations using predicator v3.0's context_location.
Functions
Assign a value to a location in the data model using the resolved path.
This performs the actual assignment operation after location validation.
Compile a value expression string into predicator instructions.
Returns {:ok, compiled} on success, {:error, reason} on failure.
Evaluate an expression and assign its result to a location in the data model.
This combines expression evaluation with location-based assignment. If a pre-compiled expression is provided, it will be used for better performance.
Evaluate a compiled expression to extract its value (not just boolean result).
Context includes:
- Current state configuration
- Current event
- Data model variables
Returns {:ok, value} on success, {:error, reason} on failure.
Resolve a location path from a string expression only (without context validation).
This is useful when you need to determine the assignment path structure before evaluating against a specific context.
Returns {:ok, path_list} on success, {:error, reason} on failure.
Resolve a location path for assignment operations using predicator v3.0's context_location.
This validates that the location is assignable and returns the path components for safe data model updates.
Returns {:ok, path_list} on success, {:error, reason} on failure.