Perinc...Result(3pm)
π Perinci::Object::EnvResult β the whole vibe π
okay bestie, so this is Perinci::Object::EnvResult, a page from the User Contributed Perl Documentation (yes, that manual). it's part of the Perinci-Object Perl distribution and honestly? it's giving organized. it's giving tidy little result objects. come sit with me π«Ά
β¨ VERSION β¨
this doc describes version 0.311 of Perinci::Object::EnvResult (from the Perl distribution Perinci-Object), and it was released on 2020-01-02. iconic behavior, truly π
πΈ SYNOPSIS πΈ
here's the whole thing in action, no cap:
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);
like look at that. every getter is also a setter. main character energy fr fr π
π¦ DESCRIPTION π¦
so basically: this class gives you an object-oriented interface for an enveloped result (peep Rinci::function if you want the whole lore on what an enveloped result even is β that's where the details live).
that's it, that's the class. it wraps the array so you don't have to keep counting indexes with your eyeballs like some kind of medieval peasant π
π METHODS π
new($res) => OBJECT
makes you a brand new object out of the $res enveloped result array. feed it the array, get a cute object back. slay β¨
new_ok([ $actual_res ]) => OBJECT
a shortcut, bestie!! it's literally just new([200,"OK",$actual_res]) β or if you don't pass $actual_res at all, it's new([200,"OK"]). so it's the "everything went great" starter pack π
$envres->status
get or set the status β that's the 1st element. one method, two jobs, we love a multitasker π
$envres->message
get or set the message β the 2nd element. π©
$envres->payload
get or set the actual payload β the 3rd element. this is the real content, the moment, the payload of the century π
$envres->meta
get or set the result metadata β the 4th element. the little side-notes, the lore, the extra credit π«
$envres->as_struct
hands you back the represented data structure. as in, the whole thing, back in array form. π§
$envres->is_success
returns true if the status is between 200-299. that's the happy zone, the green flags only zone π
π HOMEPAGE π
go visit the project's homepage at <https://metacpan.org/release/Perinci-Object>. it's right there, go look π
π«Ά SOURCE π«Ά
the source repository lives at <https://github.com/perlancar/perl-Perinci-Object>. code is code, go read it π
π BUGS π
found a bug? got a feature request? please report it on the bugtracker website over at <https://github.com/perlancar/perl-Perinci-Object/issues>. do NOT just suffer in silence, that's not the vibe π
and when you do submit a bug or a request β please, please include a test-file, or a patch to an existing test-file, that shows off the bug or the feature you want. receipts make everything easier, fr fr.
π 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.
it's free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt. π
and that's the whole page bestie, no notes π
okay so that's a wrap on Perinci::Object::EnvResult from Perl v5.36.0, dated 2022-10-13, and you absolutely ate this documentation. go build something cute with your enveloped results πβ¨π¦
π¦ where this page comes from
- ubuntu noble: libperinci-object-perl 0.311-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libperinci-object-perl 0.311-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libperinci-object-perl 0.311-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms