Solve.ControllerSpec (Solve v0.2.1)

Copy Markdown View Source

Controller specification used by Solve init and dependency validation.

Summary

Types

collect_context()

@type collect_context() :: %{dependencies: map(), app_params: term()}

collect_fun()

@type collect_fun() :: (collect_context() -> collect_result())

collect_result()

@type collect_result() :: [{Solve.Collection.id(), collected_item_opts()}]

collected_item_opts()

@type collected_item_opts() :: keyword()

collection_binding()

@type collection_binding() :: {:solve_collection_binding, atom(), nil | function()}

dependency_binding()

@type dependency_binding() :: %{
  key: atom(),
  source: atom(),
  kind: :single | :collection,
  filter: nil | (Solve.Collection.id(), map() -> boolean())
}

dependency_spec()

@type dependency_spec() :: atom() | {atom(), atom() | collection_binding()}

name()

@type name() :: atom()

t()

@type t() :: %Solve.ControllerSpec{
  callbacks: map(),
  collect: collect_fun() | nil,
  dependencies: [name()],
  dependency_bindings: [dependency_binding()],
  module: module(),
  name: name(),
  params: term(),
  variant: variant()
}

variant()

@type variant() :: :singleton | :collection

Functions

collection(source)

@spec collection(atom()) :: collection_binding()

collection(source, filter)

@spec collection(atom(), (Solve.Collection.id(), map() -> boolean())) ::
  collection_binding()

controller!(opts)

@spec controller!(keyword()) :: t()

default_params(map)

@spec default_params(term()) :: true

validate(controller_spec)

@spec validate(term()) :: {:ok, t()} | {:error, term()}

validate_many(controller_specs)

@spec validate_many(term()) :: {:ok, [t()]} | {:error, term()}