exhal v8.2.0 ExHal.Document

A document is the representaion of a single resource in HAL.

Link to this section Summary

Functions

Returns a new %ExHal.Document representing the HAL document provided.

Fetches value of specified property or links whose rel matches

Returns new ExHal.Document

Returns the link or property of the specified name, or default if neither or found.

Returns link or property of the specified name, or the result of default_fun if neither are found.

Returns [%Link{}...] when link exists or result of default otherwise.

Returns [%Link{}...] when link exists or result of default_fun otherwise.

Returns property value when property exists or default otherwise

Returns <property value> when property exists or result of default_fun otherwise

Returns true iff the document contains at least one link with the specified rel.

Returns a new %ExHal.Document representing the HAL document provided.

Add or update a property to a Document.

Returns a string representation of this HAL document.

Deprecated

Returns a map that matches the shape of the intended JSON output.

Returns {:ok, <url of specified document>} or :error.

Link to this section Types

Link to this opaque

t() (opaque)
t()

Link to this section Functions

Link to this function

%ExHal.Document{} (struct)

Returns a new %ExHal.Document representing the HAL document provided.

Link to this function

fetch(a_document, name)

Fetches value of specified property or links whose rel matches

Returns {:ok, <property value>} if name identifies a property;

    `{:ok, [%Link{}, ...]}`   if `name` identifies a link;
    `:error`                  othewise
Link to this function

from_parsed_hal(parsed_hal)
from_parsed_hal(%{}) :: ExHal.Document.t()

Returns new ExHal.Document

Link to this function

from_parsed_hal(parsed_hal, client)
from_parsed_hal(%{}, ExHal.Client.t()) :: ExHal.Document.t()
from_parsed_hal(ExHal.Client.t(), %{}) :: ExHal.Document.t()

Link to this function

get(a_doc, name, default \\ nil)

Returns the link or property of the specified name, or default if neither or found.

Link to this function

get_lazy(a_doc, name, default_fun)

Returns link or property of the specified name, or the result of default_fun if neither are found.

Link to this function

get_links(a_doc, link_name, default \\ [])

Returns [%Link{}...] when link exists or result of default otherwise.

Link to this function

get_property(a_doc, prop_name, default \\ nil)

Returns property value when property exists or default otherwise

Link to this function

get_property_lazy(a_doc, prop_name, default_fun)

Returns <property value> when property exists or result of default_fun otherwise

Link to this function

has_link?(doc, rel)

Returns true iff the document contains at least one link with the specified rel.

Link to this function

parse(hal_str, client \\ ExHal.client())

Link to this function

parse!(hal_str, client \\ ExHal.client())

Returns a new %ExHal.Document representing the HAL document provided.

Link to this function

put_link(doc, rel, target, templated \\ false)

Add a link to a Document.

Returns new ExHal.Document with the specified link.

Link to this function

put_property(doc, name, val)

Add or update a property to a Document.

Returns new ExHal.Document with the specified property set to the specified value.

Returns a string representation of this HAL document.

Link to this function

to_json_hash(doc)

Deprecated

See to_json_map/1

Link to this function

to_json_map(doc)

Returns a map that matches the shape of the intended JSON output.

Link to this function

url(a_doc, default_fn \\ fn _doc -> :error end)

Returns {:ok, <url of specified document>} or :error.