PONAPI::Document::Builder::Resource - document builder - resource
version 0.001002
use PONAPI::Document::Builder::Resource; PONAPI::Document::Builder::Resource->new( id => $id, type => $type, );
PONAPI::Document::Builder::Resource is used internally by PONAPI::Document to build {json:api} documents. Generally, these will be created by PONAPI::Document->add_resources, which will return an object that you can call add_relationship, add_attributes, and others on.
PONAPI::Document::Builder::Resource
PONAPI::Document
{json:api}
PONAPI::Document->add_resources
add_relationship
add_attributes
new( id => $id, type => $type, parent => $parent )
Create a new object. id and type are mandatory.
id
type
Parent is assigned by PONAPI::Document->add_resources, so you don't need to specify it.
Returns the id of this object.
Returns the type of this object.
add_attributes( $attr_name => $value, ... )
Adds the specified attributes to the object.
add_relationship( $relationship_name => $resource, $is_a_collection)
Adds $resource to the $relationship_name relationship for this object. Will create the relationship if it doesn't already exist.
$resource
$relationship_name
Note that trying to add multiple resources when $is_a_collection is false will result in an error.
$is_a_collection
add_links( $link_name => $url, ... )
See "add_links" in PONAPI::Document.
add_self_link
See "add_self_link" in PONAPI::Document.
add_meta
See "add_meta" in PONAPI::Document.
parent
See "parent" in PONAPI::Document.
find_root
See "find_root" in PONAPI::Document.
is_root
See "is_root" in PONAPI::Document.
Mickey Nasriachi <mickey@cpan.org>
Stevan Little <stevan@cpan.org>
Brian Fraser <hugmeir@cpan.org>
This software is copyright (c) 2017 by Mickey Nasriachi, Stevan Little, Brian Fraser.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install PONAPI::Tools, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PONAPI::Tools
CPAN shell
perl -MCPAN -e shell install PONAPI::Tools
For more information on module installation, please visit the detailed CPAN module installation guide.