View Source Arke.Core.Unit (Arke v1.1.33)

Struct which defines a Unit

  {arke_struct} = Unit

Link to this section Summary

Functions

Get the Unit data as a keyword list

Get data of all the given units

Get the value for the given data based on a key to search. Return the value to be assigned in the generate function

Edit and update a Unit by passing the Unit itself and the new data

Link to this section Functions

@spec data_as_klist(
  unit :: %Arke.Core.Unit{
    __module__: term(),
    arke_id: term(),
    data: term(),
    id: term(),
    inserted_at: term(),
    link: term(),
    metadata: term(),
    runtime_data: term(),
    updated_at: term()
  }
) :: [{:key, any()}]

Get the Unit data as a keyword list

parameters

Parameters

  • unit => %Arke.Core.Unit{} => the Unit itself

example

Example

iex> arke = Arke.Boundary.ArkeManager.get(:arke, :arke_system)
...> unit = Arke.Core.Unit.generate(arke,%{id: :test, label: "Test"})
...> data_string = Enum.map(unit.data, fn({key, value}) -> {Atom.to_string(key), value} end)
...> Arke.Core.Unit.data_as_klist(%{arke: unit.arke, data: data_string})

return

Return

[keyword: value]
Link to this function

encode_unit_data(arke, data)

View Source
@spec get_data(
  units :: [
    %Arke.Core.Unit{
      __module__: term(),
      arke_id: term(),
      data: term(),
      id: term(),
      inserted_at: term(),
      link: term(),
      metadata: term(),
      runtime_data: term(),
      updated_at: term()
    }
  ]
) :: [%{}]

Get data of all the given units

parameter

Parameter

  • units => [ %Arke.Core.Unit{}, ....] => all the units from which we want to get data

example

Example

iex> arke = Arke.Boundary.ArkeManager.get(:arke, :arke_system)
... > unit1 = Arke.Core.Unit.generate(arke,%{id: :test, label: "Test"})
... > unit2 = Arke.Core.Unit.generate(arke,%{id: :test2, label: "Test2"})
... > Arke.Core.Unit.get_data([unit1, unit2])

return

Return

[%{data unit1}, %{data unit2}]
Link to this function

get_default_value(value, parameter)

View Source
Link to this function

get_value(unit, parameter_id)

View Source
@spec get_value(
  data :: %Arke.Core.Unit{
    __module__: term(),
    arke_id: term(),
    data: term(),
    id: term(),
    inserted_at: term(),
    link: term(),
    metadata: term(),
    runtime_data: term(),
    updated_at: term()
  },
  arg2 :: atom() | String.t()
) :: String.t() | boolean() | number() | list() | %{}

Get the value for the given data based on a key to search. Return the value to be assigned in the generate function

parameters

Parameters

  • data = map | keyword => data to be parsed

  • key => :atom => key to search in the data

example

Example

iex> arke = Arke.Boundary.ArkeManager.get(:arke, :arke_system)
...> unit = Arke.Core.Unit.generate(arke,%{id: :test, label: "Test"})
...> Arke.Core.Unit.get_value(unit.data, :label)

return

Return

value
Link to this function

load(arke, opts, persistence_fn \\ :get)

View Source
Link to this function

load_data(arke, unit_data, opts)

View Source
Link to this function

load_parameter_value(_, data, opts)

View Source
Link to this function

new(id, data, arke_id, link, metadata, inserted_at, updated_at, _module__, runtime_data \\ %{})

View Source
@spec update(
  unit :: %Arke.Core.Unit{
    __module__: term(),
    arke_id: term(),
    data: term(),
    id: term(),
    inserted_at: term(),
    link: term(),
    metadata: term(),
    runtime_data: term(),
    updated_at: term()
  },
  args :: [{:key, any()}] | map()
) :: %Arke.Core.Unit{
  __module__: term(),
  arke_id: term(),
  data: term(),
  id: term(),
  inserted_at: term(),
  link: term(),
  metadata: term(),
  runtime_data: term(),
  updated_at: term()
}

Edit and update a Unit by passing the Unit itself and the new data

example

Example

iex> arke = Arke.Boundary.ArkeManager.get(:arke, :arke_system)
...> unit = Arke.Core.Unit.generate(arke,%{id: :test, label: "Test"})
...> Arke.Core.Unit.update(unit, [label: "Test updated"] )

## Return

 %Arke.Core.Unit{}