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

NAME

Perinci::Object::EnvResult - Represent enveloped result

VERSION

version 0.13

SYNOPSIS

 use Perinci::Object::Result;
 use Data::Dump; # for dd()

 my $rires = Perinci::Object::Result->new([200, "OK", [1, 2, 3]]);
 dd $rires->is_success, # 1
    $rires->status,     # 200
    $rires->message,    # "OK"
    $rires->payload,    # [1, 2, 3]
    $rires->meta,       # undef
    $rires->as_struct;  # [200, "OK", [1, 2, 3]]

 # setting status, message, result, extra
 $rires->status(404);
 $rires->message('Not found');
 $rires->payload(undef);
 $rires->meta({errno=>-100});

 # shortcut: create a new OK result ([200, "OK"] or [200, "OK", $payload])
 $rires = Perinci::Object::Result->new_ok();
 $rires = Perinci::Object::Result->new_ok(42);

DESCRIPTION

This class provides an object-oriented interface for enveloped result (see Rinci::function for more details).

METHODS

new($res) => OBJECT

Create a new object from $res enveloped result array.

$ssres->status

Get or set status (the 1st element).

$ssres->message

Get or set message (the 2nd element).

$ssres->payload

Get or set the actual payload (the 3rd element).

$ssres->meta

Get or set result metadata (the 4th element).

$ssres->as_struct

Return the represented data structure.

$ssres->is_success

True if status is between 200-299.

SEE ALSO

Perinci::Object

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Perinci-Object.

SOURCE

Source repository is at https://github.com/sharyanto/perl-Perinci-Object.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-Object

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Steven Haryanto.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.