The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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 and type 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, ... )

    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.

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.