NAME
PONAPI::Document::Builder::Resource - document builder - resource
VERSION
version 0.001002
SYNOPSIS
use PONAPI::Document::Builder::Resource;
PONAPI::Document::Builder::Resource->new(
id => $id,
type => $type,
);
DESCRIPTION
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.
METHODS
new( id => $id, type => $type, parent => $parent )
Create a new object.
id
andtype
are mandatory.Parent is assigned by
PONAPI::Document->add_resources
, so you don't need to specify it.id
Returns the id of this object.
type
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.Note that trying to add multiple resources when
$is_a_collection
is false will result in an error.add_links( $link_name => $url, ... )
add_self_link
add_meta
parent
find_root
is_root
AUTHORS
Mickey Nasriachi <mickey@cpan.org>
Stevan Little <stevan@cpan.org>
Brian Fraser <hugmeir@cpan.org>
COPYRIGHT AND LICENSE
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.