StructInspect.Opts (struct_inspect v0.1.4)

View Source

Provides a struct to configure the behavior of StructInspect.

Summary

Functions

Applies the given attributes to the default options.

Changes an existing StructInspect.Opts struct with new ommits.

Creates a new StructInspect.Opts struct.

Types

attributes()

@type attributes() :: t() | map() | keyword() | [atom()] | atom()

t()

@type t() :: %StructInspect.Opts{
  empty_list: boolean(),
  empty_map: boolean(),
  empty_string: boolean(),
  empty_struct: boolean(),
  empty_tuple: boolean(),
  except: list(),
  false_value: boolean(),
  nil_value: boolean(),
  true_value: boolean(),
  zero_float_value: boolean(),
  zero_integer_value: boolean()
}

Functions

apply_to_defaults(attrs \\ [])

@spec apply_to_defaults(attributes()) :: t()

Applies the given attributes to the default options.

The default options are taken from the application environment.

Parameters

  • attrs (attributes()) - The attributes to apply. Defaults to [].

Returns

t() - A new StructInspect.Opts struct with the applied attributes.

change(options, ommits)

@spec change(t(), attributes()) :: t()

Changes an existing StructInspect.Opts struct with new ommits.

Parameters

  • options (t()) - The options struct to change.
  • ommits (attributes()) - The new ommits to apply.

Returns

t() - The modified StructInspect.Opts struct.

new(ommits \\ [])

@spec new(attributes()) :: t()

Creates a new StructInspect.Opts struct.

It can receive:

  • A map or keyword list of ommits to override the default values.
  • A list of atoms, where only the named keys are set to true and the rest to false.
  • Another StructInspect.Opts struct, which is returned as is.
  • Nothing, in which case it returns the default struct.

Parameters

  • ommits (attributes()) - The ommits to create the struct. Defaults to nil.

Returns

t() - A new StructInspect.Opts struct.