.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Perinci::Object 3pm" .TH Perinci::Object 3pm "2021-01-07" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Perinci::Object \- Object\-oriented interface for Rinci metadata .SH "VERSION" .IX Header "VERSION" This document describes version 0.311 of Perinci::Object (from Perl distribution Perinci-Object), released on 2020\-01\-02. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Perinci::Object; # automatically exports risub(), rivar(), ripkg(), \& # envres(), envresmulti(), envrestable(), riresmeta() \& use Data::Dump; # for dd() \& \& # OO interface to function metadata. \& \& my $risub = risub { \& v => 1.1, \& summary => \*(AqCalculate foo and bar\*(Aq, \& "summary.alt.lang.id_ID" => \*(AqMenghitung foo dan bar\*(Aq, \& args => { a1 => { schema => \*(Aqint*\*(Aq }, a2 => { schema => \*(Aqstr\*(Aq } }, \& features => { pure=>1 }, \& }; \& dd $risub\->type, # "function" \& $risub\->v, # 1.1 \& $risub\->arg(\*(Aqa1\*(Aq), # { schema=>\*(Aqint*\*(Aq } \& $risub\->arg(\*(Aqa3\*(Aq), # undef \& $risub\->feature(\*(Aqpure\*(Aq), # 1 \& $risub\->feature(\*(Aqfoo\*(Aq), # undef \& $risub\->langprop(\*(Aqsummary\*(Aq), # \*(AqCalculate foo and bar\*(Aq \& $risub\->langprop({lang=>\*(Aqid_ID\*(Aq}, \*(Aqsummary\*(Aq), # \*(AqMenghitung foo dan bar\*(Aq \& \& # setting arg and property \& $risub\->arg(\*(Aqa3\*(Aq, \*(Aqarray\*(Aq); # will actually fail for 1.0 metadata \& $risub\->feature(\*(Aqfoo\*(Aq, 2); # ditto \& \& # OO interface to variable metadata \& \& my $rivar = rivar { ... }; \& \& # OO interface to package metadata \& \& my $ripkg = ripkg { ... }; \& \& # OO interface to enveloped result \& \& my $envres = envres [200, "OK", [1, 2, 3]]; \& dd $envres\->is_success, # 1 \& $envres\->status, # 200 \& $envres\->message, # "OK" \& $envres\->result, # [1, 2, 3] \& $envres\->meta; # undef \& \& # setting status, message, result, extra \& $envres\->status(404); \& $envres\->message(\*(AqNot found\*(Aq); \& $envres\->result(undef); \& $envres\->meta({errno=>\-100}); \& \& # OO interface to function/method result metadata \& my $riresmeta = riresmeta { ... }; \& \& # an example of using envresmulti() \& sub myfunc { \& ... \& \& my $envres = envresmulti(); \& \& # add result for each item \& $envres\->add_result(200, "OK", {item_id=>1, payload=>"a"}); \& $envres\->add_result(202, "OK", {item_id=>2, note=>"blah", payload=>"b"}); \& $envres\->add_result(404, "Not found", {item_id=>3}); \& ... \& \& # finally, return the result \& return $envres\->as_struct; \& } \& \& # an example of using envrestable() \& sub myfunc { \& ... \& my $envres = envrestable(); \& $envres\->add_field(\*(Aqfoo\*(Aq); \& $envres\->add_field(\*(Aqbar\*(Aq); \& ... \& return $envres\->as_struct; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Rinci works using pure data structures, but sometimes it's convenient to have an object-oriented interface (wrapper) for those data. This module provides just that. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .ie n .SS "rimeta $meta => \s-1OBJECT\s0" .el .SS "rimeta \f(CW$meta\fP => \s-1OBJECT\s0" .IX Subsection "rimeta $meta => OBJECT" Exported by default. A shortcut for Perinci::Object::Metadata\->new($meta). .ie n .SS "risub $meta => \s-1OBJECT\s0" .el .SS "risub \f(CW$meta\fP => \s-1OBJECT\s0" .IX Subsection "risub $meta => OBJECT" Exported by default. A shortcut for Perinci::Object::Function\->new($meta). .ie n .SS "rivar $meta => \s-1OBJECT\s0" .el .SS "rivar \f(CW$meta\fP => \s-1OBJECT\s0" .IX Subsection "rivar $meta => OBJECT" Exported by default. A shortcut for Perinci::Object::Variable\->new($meta). .ie n .SS "ripkg $meta => \s-1OBJECT\s0" .el .SS "ripkg \f(CW$meta\fP => \s-1OBJECT\s0" .IX Subsection "ripkg $meta => OBJECT" Exported by default. A shortcut for Perinci::Object::Package\->new($meta). .ie n .SS "envres $res => \s-1OBJECT\s0" .el .SS "envres \f(CW$res\fP => \s-1OBJECT\s0" .IX Subsection "envres $res => OBJECT" Exported by default. A shortcut for Perinci::Object::EnvResult\->new($res). .ie n .SS "envresmulti $res => \s-1OBJECT\s0" .el .SS "envresmulti \f(CW$res\fP => \s-1OBJECT\s0" .IX Subsection "envresmulti $res => OBJECT" Exported by default. A shortcut for Perinci::Object::EnvResultMulti\->new($res). .ie n .SS "envrestable $res => \s-1OBJECT\s0" .el .SS "envrestable \f(CW$res\fP => \s-1OBJECT\s0" .IX Subsection "envrestable $res => OBJECT" Exported by default. A shortcut for Perinci::Object::EnvResultTable\->new($res). .ie n .SS "riresmeta $resmeta => \s-1OBJECT\s0" .el .SS "riresmeta \f(CW$resmeta\fP => \s-1OBJECT\s0" .IX Subsection "riresmeta $resmeta => OBJECT" Exported by default. A shortcut for Perinci::Object::ResMeta\->new($res). .SH "HOMEPAGE" .IX Header "HOMEPAGE" Please visit the project's homepage at . .SH "SOURCE" .IX Header "SOURCE" Source repository is at . .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests on the bugtracker website .PP 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. .SH "SEE ALSO" .IX Header "SEE ALSO" Rinci .SH "AUTHOR" .IX Header "AUTHOR" perlancar .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2021, 2017, 2016, 2015, 2014, 2013, 2012, 2011 by perlancar@cpan.org. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.