# `Poney.Ref`
[🔗](https://github.com/hattoriai/poney-elixir/blob/v0.1.0/lib/poney/ref.ex#L1)

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`).

# `kind`

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

# `t`

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

# `key`

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

The text form of a ref.

# `parse`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
