Provided by: libperinci-object-perl_0.311-2_all
NAME
Perinci::Object::EnvResult - Represent enveloped result
VERSION
This document describes version 0.311 of Perinci::Object::EnvResult (from Perl distribution Perinci-Object), released on 2020-01-02.
SYNOPSIS
use Perinci::Object::EnvResult; use Data::Dump; # for dd() my $envres = Perinci::Object::EnvResult->new([200, "OK", [1, 2, 3]]); dd $envres->is_success, # 1 $envres->status, # 200 $envres->message, # "OK" $envres->payload, # [1, 2, 3] $envres->meta, # undef $envres->as_struct; # [200, "OK", [1, 2, 3]] # setting status, message, result, extra $envres->status(404); $envres->message('Not found'); $envres->payload(undef); $envres->meta({errno=>-100}); # shortcut: create a new OK result ([200, "OK"] or [200, "OK", $payload]) $envres = Perinci::Object::EnvResult->new_ok(); $envres = Perinci::Object::EnvResult->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. new_ok([ $actual_res ]) => OBJECT Shortcut for "new([200,"OK",$actual_res])", or just "new([200,"OK"])" if $actual_res is not specified. $envres->status Get or set status (the 1st element). $envres->message Get or set message (the 2nd element). $envres->payload Get or set the actual payload (the 3rd element). $envres->meta Get or set result metadata (the 4th element). $envres->as_struct Return the represented data structure. $envres->is_success True if status is between 200-299.
HOMEPAGE
Please visit the project's homepage at <https://metacpan.org/release/Perinci-Object>.
SOURCE
Source repository is at <https://github.com/perlancar/perl-Perinci-Object>.
BUGS
Please report any bugs or feature requests on the bugtracker website <https://github.com/perlancar/perl-Perinci-Object/issues> 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.
SEE ALSO
Perinci::Object
AUTHOR
perlancar <perlancar@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2021, 2017, 2016, 2015, 2014, 2013, 2012, 2011 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.