Apicult.Result (Apicult v0.2.0) View Source

Link to this section Summary

Types

A field in a result

A result definition in a an apicult. It looks like json except you can have ... in an object mention there are additional fields (the rest)

Functions

Generate a struct corresponding to a result definition.

Parse a string as a result definition.

Populates a struct from a map, using a result definition.

Link to this section Types

Specs

field() :: {:field, key :: atom(), value :: term() | result()} | [field()]

A field in a result

The value may be:

  • a simple json value (string or number),
  • a result/0 for nested objects,
  • a list of field/0 (always with a single item) to signify a list.

Specs

result() :: {:result, fields :: [field()], has_rest? :: boolean()}

A result definition in a an apicult. It looks like json except you can have ... in an object mention there are additional fields (the rest)

Link to this section Functions

Link to this function

generate_struct(name, definition)

View Source

Generate a struct corresponding to a result definition.

Specs

parse(String.t()) :: result()

Parse a string as a result definition.

Link to this function

result_to_map(result_struct, arg, attrs)

View Source

Populates a struct from a map, using a result definition.

This method is called by from_map/1 in the struct generated by generate_struct/2.