View Source Smokestack.ParamBuilder (smokestack v0.9.2)

Handles the building of parameters.

Summary

Types

Encode the result using the specified encoder.

Format the keys in the specified case. Defaults to :snake

Convert the keys into the specified type. Defaults to :atom.

Nest the result within the specified key in the output.

Functions

Run the factory and return a map or list-of-maps of params.

Types

encode_option()

@type encode_option() :: {:encode, module()}

Encode the result using the specified encoder.

Smokestack will call encode/1 on the module provided with the generated result (or results). For example set encode: Jason or encode: Poison to encode the results as a JSON string.

The module's encode function should return an ok/error tuple.

error()

key_case_option()

@type key_case_option() ::
  {:key_case,
   :camel
   | :constant
   | :dot
   | :header
   | :kebab
   | :name
   | :pascal
   | :path
   | {:path, separator :: String.t()}
   | :sentence
   | :snake
   | :title}

Format the keys in the specified case. Defaults to :snake

key_type_option()

@type key_type_option() :: {:key_type, :string | :atom}

Convert the keys into the specified type. Defaults to :atom.

nest_option()

@type nest_option() :: {:nest, String.t() | atom()}

Nest the result within the specified key in the output.

option()

result()

@type result() :: %{required(String.t() | atom()) => any()}

Functions

build(factory, options)

@spec build(Smokestack.Dsl.Factory.t(), [option()]) ::
  {:ok, result()} | {:error, error()}

Run the factory and return a map or list-of-maps of params.