View Source Arke.StructManager (Arke v1.1.33)

Module that provides function for getting Arke and Unit structs. It also provides functions for encoding and decoding Units.

Link to this section Summary

Functions

Function that decodes data into a Unit or list of Unit

Function that encodes a Unit or list of Unit

Function that returns a Struct that describes an Arke or a Unit

Link to this section Types

@type parameter() :: %{
  default: String.t() | boolean() | atom() | map() | list() | nil,
  helper_text: String.t() | nil,
  id: String.t(),
  label: String.t(),
  required: boolean() | nil,
  type: String.t(),
  key: String.t() | boolean() | atom() | map() | list() | nil
}

Link to this section Functions

Link to this function

decode(project, arke_id, json, arg4)

View Source
@spec decode(
  project :: atom(),
  arke_id :: atom(),
  json :: %{key: String.t() | number() | boolean() | atom()},
  format :: atom()
) :: Arke.Core.Unit.t()

Function that decodes data into a Unit or list of Unit

parameters

Parameters

  • project => :atom => identify the Arke.Core.Project
  • arke_id => atom | string => arke id

  • json => %{key: value} => json data that we want to decode
  • type => :json => data input type

example

Example

iex> StructManager.decode(:arke, my_json_data, :json)
Link to this function

encode(unit, opts \\ [])

View Source
@spec encode(unit :: Arke.Core.Unit.t(), format :: atom()) :: %{
  key: String.t() | number() | boolean() | atom()
}

Function that encodes a Unit or list of Unit

parameters

Parameters

  • unit => [%{arke_struct}] | %{arke_struct} => unit or list of units that we want to encode

  • type => :json => desired encode type

example

Example

iex> units = QueryManager.filter_by(arke_id: id)
...> StructManager.encode(units, type: :json)
@spec get_struct(arke :: Arke.Core.Unit.t()) :: %{
  parameters: [parameter()],
  label: String.t()
}

Function that returns a Struct that describes an Arke or a Unit

parameters

Parameters

  • unit => %Unit{} | %Arke{} => unit or arke struct

example

Example

  iex> arke = ArkeManager.get(:test, :default)
  ...> StructManager.get_struct(arke)
@spec get_struct(arke :: Arke.Core.Unit.t(), opts :: list()) :: %{
  parameters: [parameter()],
  label: String.t()
}
Link to this function

get_struct(arke, unit, opts)

View Source
Link to this function

validate_data(id, value, arke, opts \\ [])

View Source