Estructura.Full (estructura v1.9.0)

View Source

Full Example

Summary

Functions

Returns the generator to be used in StreamData-powered property testing, based on the specification given to use Estructura, which contained

Gets the value for the given key from the structure

Puts the value for the given key into the structure, passing coercion and validation, returns {:ok, updated_struct} or {:error, reason} if there is no such key

Puts the value for the given key into the structure, passing coercion and validation, returns the value or raises if there is no such key

Recalculates calculated fields for the instance of Estructura.Full.

Functions

__generator__()

@spec __generator__() ::
  StreamData.t(%Estructura.Full{
    bar: term(),
    baz: term(),
    foo: term(),
    zzz: term()
  })

See Estructura.Full.__generator__/1

__generator__(this)

@spec __generator__(%Estructura.Full{
  bar: term(),
  baz: term(),
  foo: term(),
  zzz: term()
}) ::
  StreamData.t(%Estructura.Full{
    bar: term(),
    baz: term(),
    foo: term(),
    zzz: term()
  })

Returns the generator to be used in StreamData-powered property testing, based on the specification given to use Estructura, which contained

shape

%Estructura.Config{
  access: true,
  coercion: [:foo],
  validation: true,
  calculated: [],
  collectable: :bar,
  enumerable: true,
  generator: [
    foo: {StreamData, :integer, [0..1000]},
    bar: {StreamData, :string, [:alphanumeric]},
    baz: {StreamData, :fixed_map,
     [[key1: {StreamData, :integer}, key2: {StreamData, :integer}]]},
    zzz: &Estructura.Full.zzz_generator/0
  ]
}

The argument given would be used as a template to generate new values.

get(data, key, default \\ nil)

@spec get(
  %Estructura.Full{bar: term(), baz: term(), foo: term(), zzz: term()},
  Estructura.Config.key(),
  any()
) :: any()

Gets the value for the given key from the structure

put(data, key, value)

@spec put(
  %Estructura.Full{bar: term(), baz: term(), foo: term(), zzz: term()},
  Estructura.Config.key(),
  any()
) ::
  {:ok, %Estructura.Full{bar: term(), baz: term(), foo: term(), zzz: term()}}
  | {:error, any()}

Puts the value for the given key into the structure, passing coercion and validation, returns {:ok, updated_struct} or {:error, reason} if there is no such key

put!(data, key, value)

@spec put!(
  %Estructura.Full{bar: term(), baz: term(), foo: term(), zzz: term()},
  Estructura.Config.key(),
  any()
) ::
  %Estructura.Full{bar: term(), baz: term(), foo: term(), zzz: term()}
  | no_return()

Puts the value for the given key into the structure, passing coercion and validation, returns the value or raises if there is no such key

recalculate_calculated(data)

Recalculates calculated fields for the instance of Estructura.Full.

Normally one would not need to call this function explicitly because Access implementation would do that.