Poney.Ref (Poney v0.1.0)

Copy Markdown View Source

A reference to one element of a document, as walkthroughs write it (§5.8): "<kind>:<id>", "<kind>:<behavior>:<id>" for the parts of a behavior, "group:<view>:<id>" for a group of a view, and "dataType:<id>#<field>" for a field.

iex> Poney.Ref.parse("transition:order-lifecycle:t-retry")
{:ok, %Poney.Ref{kind: :transition, behavior: "order-lifecycle", id: "t-retry"}}

iex> to_string(%Poney.Ref{kind: :data_type, id: "orders", field: "status"})
"dataType:orders#status"

Kinds are atoms in snake case (:data_type, :use_case); the text form keeps the format's names (dataType, useCase).

Summary

Functions

The text form of a ref.

Parses a ref key. Text that is not a ref gives :error.

Types

kind()

@type kind() ::
  :entity
  | :relationship
  | :use_case
  | :data_flow
  | :data_relation
  | :behavior
  | :data_type
  | :group
  | :message
  | :fragment
  | :state
  | :transition
  | :activity_node
  | :activity_flow

t()

@type t() :: %Poney.Ref{
  behavior: String.t() | nil,
  field: String.t() | nil,
  id: String.t(),
  kind: kind(),
  view: String.t() | nil
}

Functions

key(ref)

@spec key(t()) :: String.t()

The text form of a ref.

parse(text)

@spec parse(String.t()) :: {:ok, t()} | :error

Parses a ref key. Text that is not a ref gives :error.