Reactor.Argument (reactor v0.10.3)

View Source

A step argument.

Summary

Functions

Build an argument which refers to to an element within a map step with an optional transformation applied.

Build an argument which refers to a reactor input with an optional transformation applied.

Build an argument which refers to the result of another step with an optional transformation applied.

Build an argument directly from a template.

Build an argument which refers to a statically defined value.

Validate that the argument source has a sub_path

Validate that the argument has a transform.

Validate that the argument is an Argument struct.

Validate that the argument contains an element.

Validate that the argument refers to a reactor input.

Validate that the argument refers to a step result.

Validate that the argument contains a static value.

Set a sub-path on the argument.

Types

t()

@type t() :: %Reactor.Argument{
  name: atom(),
  source: Reactor.Template.t(),
  transform: nil | (any() -> any()) | {module(), keyword()} | mfa()
}

Functions

from_element(name, element_name, transform \\ nil)

@spec from_element(atom(), atom(), nil | (any() -> any())) :: t()

Build an argument which refers to to an element within a map step with an optional transformation applied.

Example

iex> Argument.from_element(:argument_name, &Atom.to_string/1)

from_input(name, input_name, transform \\ nil)

@spec from_input(atom(), atom(), nil | (any() -> any())) :: t()

Build an argument which refers to a reactor input with an optional transformation applied.

Example

iex> Argument.from_input(:argument_name, :input_name, &String.to_integer/1)

from_result(name, result_name, transform \\ nil)

@spec from_result(atom(), any(), nil | (any() -> any())) :: t()

Build an argument which refers to the result of another step with an optional transformation applied.

Example

iex> Argument.from_result(:argument_name, :step_name, &Atom.to_string/1)

from_template(name, template, transform \\ nil)

@spec from_template(atom(), Reactor.Template.t(), nil | (any() -> any())) :: t()

Build an argument directly from a template.

Example

iex> Argument.from_template(:argument_name, Reactor.Dsl.Argument.input(:input_name))

from_value(name, value, transform \\ nil)

@spec from_value(atom(), any(), nil | (any() -> any())) :: t()

Build an argument which refers to a statically defined value.

Example

iex> Argument.from_value(:argument_name, 10)

has_sub_path(argument)

(macro)

Validate that the argument source has a sub_path

has_transform(argument)

(macro)

Validate that the argument has a transform.

is_argument(argument)

(macro)

Validate that the argument is an Argument struct.

is_from_element(argument)

(macro)

Validate that the argument contains an element.

is_from_input(argument)

(macro)

Validate that the argument refers to a reactor input.

is_from_result(argument)

(macro)

Validate that the argument refers to a step result.

is_from_value(argument)

(macro)

Validate that the argument contains a static value.

sub_path(argument, sub_path)

@spec sub_path(t(), [any()]) :: t()

Set a sub-path on the argument.

Example

iex> Argument.from_value(:example, :value)
...> |> Argument.sub_path([:nested, :values])