ash/lib/ash/flow/step_helpers.ex
Zach Daniel b20c4afd9b improvement: haltable flows, branch step type
fix: fix chart links rendering
2022-10-06 17:04:44 -04:00

41 lines
1.1 KiB
Elixir

defmodule Ash.Flow.StepHelpers do
@moduledoc "Template functions available while declaring steps."
@doc "Accesses a flow argument"
def arg(name) do
{:_arg, name}
end
@doc "Accesses a flow argument"
def merge(results) do
{:_merge, results}
end
@doc "Constructs an expression that can access"
defmacro expr(expr) do
quote do
require Ash.Expr
{:_expr, Ash.Expr.expr(unquote(expr))}
end
end
@doc "Accesses the result of a step"
def result(step) do
{:_result, step}
end
@doc "Accesses a path in a value lazily. Supports the value being a template, e.g `path(result(:foo), [:bar, 0, :baz])`"
def path(template, path) do
{:_path, template, List.wrap(path)}
end
@doc "Creates a range lazily. Supports the start or finish being a template, e.g `range(result(:foo), result(:bar))`"
def range(start, finish) do
{:_range, start, finish}
end
@doc "Accesses the value being iterated over for a given map step. The name is required so that `map` steps can be nested."
def element(element) do
{:_element, element}
end
end