View Source Flamel.Chain (flamel v1.10.0)

Represents a chain of functions that can be executed in a pipeline.

Summary

Types

t()

Flamel.Chain

Functions

Applies a function to the value of the chain. If the function returns a {:ok, value} the chain's value is updated. If the function returns a {:error, reason, value} then the chain is halted and not further functions will be applied. The chain's reason will be set to the reason provided in the error tuple.

Creates a function that can be used with Enum.map/1 to build a chain for each item in the enumerable.

Create a new chain with a value. The value is the value that the chain's functions are applied to.

Types

@type t() :: %Flamel.Chain{assigns: map(), halt?: boolean(), reason: binary()}

Flamel.Chain

@type value() :: any()

Functions

Applies a function to the value of the chain. If the function returns a {:ok, value} the chain's value is updated. If the function returns a {:error, reason, value} then the chain is halted and not further functions will be applied. The chain's reason will be set to the reason provided in the error tuple.

@spec curry((value() -> value())) :: (value() -> value())

Creates a function that can be used with Enum.map/1 to build a chain for each item in the enumerable.

@spec new(value()) :: t()

Create a new chain with a value. The value is the value that the chain's functions are applied to.

@spec to_tuple(t()) :: {:ok, value()} | {:error, String.t(), value()}
@spec to_value(t()) :: value()