exhal v4.4.0 ExHal.Document

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

Summary

Functions

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

Fetches value of specified property or links whose rel matches

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_fun 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 a link to a Document

Add or update a property to a Document

Returns a string representation of this HAL document

Deprecated

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

Functions

__struct__()

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

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
from_parsed_hal(parsed_hal, client \\ ExHal.client())

Returns new ExHal.Document

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.

get_property_lazy(a_doc, prop_name, default_fun)

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

has_link?(doc, rel)

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

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

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

put_link(doc, rel, target)

Add a link to a Document.

Returns new ExHal.Document with the specified link.

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.

render!(doc)

Returns a string representation of this HAL document.

to_json_hash(doc)

Deprecated

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

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

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