Perinci::Object::EnvResult - Represent enveloped result
version 0.08
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);
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.
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.
Perinci::Object
Steven Haryanto <stevenharyanto@gmail.com>
This software is copyright (c) 2012 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.
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.