Data::HAL::Link(3pm)
π Data::HAL::Link β hypertext application language link, but make it a whole vibe π
okay so bestie, welcome to Data::HAL::Link from the Data::HAL family. This is a Perl thing. It's a link object. It's giving "structured hypermedia" and honestly? It ate. Let's get into it π«Ά
β¨ VERSION β¨
This doc is describing Data::HAL::Link version 1.001. Yes queen, that's the one. π
πΈ SYNOPSIS πΈ
map { +{
href => $_->href->uri->as_string,
rel => $_->relation->uri->as_string
} } @{ $resource->links }
look at her go. that's the whole flex. β¨
π¦ DESCRIPTION π¦
Okay so this next bit? This is completely quoted from the specification β not me, not the author, the spec said it first:
A Link Object represents a hyperlink from the containing resource to a URI.
periodt. that's the definition. iconic. π
π INTERFACE π
π Composition π
None.
like... nothing. zero. empty. it's an independent girlboss, no parent classes, no role drama. π
π Constructors π
newβ the glow-up moment where your object gets born π±
So here's the tea on this one: when the deprecation attribute is set, the constructor logs a Log::Any warning. And the warning is literally this string, verbatim:
"The link (relation: "%s", href: "%s") is deprecated, see <%s>"
You can absolutely consume that warning with a Log::Any::Adapter of your choosing, bestie β your logs, your rules. For example:
use Log::Any::Adapter 'Stderr';
Otherwise β meaning if deprecation isn't set β the constructor just behaves like the default Moo constructor. Chill. Normal. No notes. It returns a Data::HAL::Link object. π
π Attributes π
Before we go attribute by attribute: Perl strings are coerced to the Data::HAL::URI type in the attributes relation, href, deprecation, and profile. So you can hand her a plain string and she'll handle the conversion herself. queen behavior. π
relationβ TypeData::HAL::URI, required, the link relation. Spec corner: <http://tools.ietf.org/html/draft-kelly-json-hal#section-8.2>hrefβ TypeData::HAL::URI, required, the link target URI or URI template. Spec corner: <http://tools.ietf.org/html/draft-kelly-json-hal#section-5.1>templatedβ Typeboolean, tells you whetherhrefis a URI template. Spec corner: <http://tools.ietf.org/html/draft-kelly-json-hal#section-5.2>
also! Perl boolean values are coerced to the boolean type. no cap. β¨
typeβ TypeMIME::Type, the media type of thehrefresource. Spec corner: <http://tools.ietf.org/html/draft-kelly-json-hal#section-5.3>deprecationβ TypeData::HAL::URI; if it exists, it indicates the link is deprecated. Spec corner: <http://tools.ietf.org/html/draft-kelly-json-hal#section-5.4>
heads up bestie: setting this attribute triggers a log message in the constructor new. that's the warning from up above. you've been warned fr fr π
nameβ TypeStr, a secondary key for selecting link objects which share the same relation type. Spec corner: <http://tools.ietf.org/html/draft-kelly-json-hal#section-5.5>profileβ TypeData::HAL::URI, the RFC 6906 profile of the target resource. Spec corner: <http://tools.ietf.org/html/draft-kelly-json-hal#section-5.6>titleβ TypeStr, labels the link with a human-readable identifier. Spec corner: <http://tools.ietf.org/html/draft-kelly-json-hal#section-5.7>hreflangβ TypeStr, indicates the language of the target resource. Spec corner: <http://tools.ietf.org/html/draft-kelly-json-hal#section-5.8>
π§ Methods π§
as_http_link_valueβ returns the link as an RFC 5988link-valuestring, per <http://tools.ietf.org/html/rfc5988#section-5>. for example, she'll hand you back this exact string:
"</orders?page=2>;rel="next""
that's the little string format. slay. πΏ
π Exports π
None.
nothing gets exported. no surprise symbols landing in your namespace. it's giving boundaries. π
π DIAGNOSTICS π
Go look at the new constructor, bestie β that's where the warning lives. (See "new" constructor.)
π CONFIGURATION AND ENVIRONMENT π
Requires no configuration files or environment variables.
none. zero. nada. it just works. aesthetic. β¨
and that's the whole page!! π huge thanks to the perl crew β this doc shipped with perl v5.36.0 and the page itself is dated 2022-08-28, under the Data::HAL::Link(3pm) manual. go forth and hyperlink responsibly, bestie. mwah π«Άπ
π
π¦ where this page comes from
- ubuntu noble: libdata-hal-perl 1.001-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdata-hal-perl 1.001-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdata-hal-perl 1.001-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms