Perinci::Object::EnvResult - Represent enveloped result
This document describes version 0.311 of Perinci::Object::EnvResult (from Perl distribution Perinci-Object), released on 2020-01-02.
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);
This class provides an object-oriented interface for enveloped result (see Rinci::function for more details).
Create a new object from $res enveloped result array.
Shortcut for new([200,"OK",$actual_res]), or just new([200,"OK"]) if $actual_res is not specified.
new([200,"OK",$actual_res])
new([200,"OK"])
$actual_res
Get or set status (the 1st element).
Get or set message (the 2nd element).
Get or set the actual payload (the 3rd element).
Get or set result metadata (the 4th element).
Return the represented data structure.
True if status is between 200-299.
Please visit the project's homepage at https://metacpan.org/release/Perinci-Object.
Source repository is at https://github.com/perlancar/perl-Perinci-Object.
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.
Perinci::Object
perlancar <perlancar@cpan.org>
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.
To install Perinci::Object, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perinci::Object
CPAN shell
perl -MCPAN -e shell install Perinci::Object
For more information on module installation, please visit the detailed CPAN module installation guide.