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 a link to a Document.
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
t()
(opaque)
t()
t()
Link to this section Functions
%ExHal.Document{} (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)
from_parsed_hal(%{}) :: ExHal.Document.t()
from_parsed_hal(%{}) :: ExHal.Document.t()
Returns new ExHal.Document
from_parsed_hal(parsed_hal, client)
from_parsed_hal(%{}, ExHal.Client.t()) :: ExHal.Document.t()
from_parsed_hal(ExHal.Client.t(), %{}) :: ExHal.Document.t()
from_parsed_hal(%{}, ExHal.Client.t()) :: ExHal.Document.t()
from_parsed_hal(ExHal.Client.t(), %{}) :: ExHal.Document.t()
get(a_doc, name, default \\ nil)
Returns the link or property of the specified name, or default
if
neither or found.
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_links(a_doc, link_name, default \\ [])
Returns [%Link{}...]
when link exists or result of default
otherwise.
get_links_lazy(a_doc, link_name, default_fun)
Returns [%Link{}...]
when link exists or result of default_fun
otherwise.
get_property(a_doc, prop_name, default \\ nil)
Returns property value when property exists or default
otherwise
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, templated \\ false)
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
See to_json_map/1
to_json_map(doc)
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
.