The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Perinci::Access::Perl - Access Perl module, functions, variables through Riap

VERSION

This document describes version 0.70 of Perinci::Access::Perl (from Perl distribution Perinci-Access-Perl), released on 2014-08-24.

SYNOPSIS

First write your code and add Rinci metadata to them:

 package MyMod::MySubMod;

 our %SPEC;

 $SPEC{':package'} = {
     v => 1.1,
     summary => 'This package is blah blah',
 };

 $SPEC{'$var1'} = {
     v => 1.1,
     summary => 'This variable is blah blah',
 };
 our $var1;

 $SPEC{func1} = {
     v => 1.1,
     summary => 'This function does blah blah',
     args => {
         a => { schema => 'int', req => 1 },
         b => { schema => 'int' },
     },
 };
 sub func1 {
     ...
 }
 1;

then access them through Riap:

 use Perinci::Access::Perl;
 my $pa = Perinci::Access::Perl->new;

 # call function
 $res = $pa->request(call => '/MyMod/MySubMod/func1', {args=>{a=>1, b=>2}});

 # get variables
 $res = $pa->request(get => '/MyMod/MySubMod/$var1');

DESCRIPTION

This class allows you to access Perl modules, functions, and variables through Riap. Only those which have Rinci metadata are accessible. The metadata is put in %SPEC package variables, with function names as keys, or :package for package metadata, or $NAME for variables. Functions will be wrapped before executed (unless you pass wrap => 0 to the constructor).

You should probably use this through Perinci::Access.

FUNCTIONS

new(%opts) => OBJ

Constructor. For a list of options, see superclass Perinci::Access::Schemeless except for package_prefix which are not recognized by this class.

$pa->request($action, $uri, \%extras) => RESP

$pa->parse_url($url) => HASH

FAQ

Why %SPEC (instead of %META, %METADATA, %RINCI, etc)?

The name was first chosen during Sub::Spec era (see BackPAN) in 2011, it stuck. By that time I already had had a lot of code written using %SPEC.

Why wrap?

The wrapping process accomplishes several things, among others: checking of metadata, normalization of schemas in metadata, also argument validation and exception trapping in function.

The function wrapping introduces a small overhead when performing a sub call (typically around several to tens of microseconds on an Intel Core i5 1.7GHz notebook). This is usually smaller than the overhead of Perinci::Access::Perl itself (typically in the range of 100 microseconds). But if you are concerned about the wrapping overhead, see the wrap => 0 option.

SEE ALSO

Perinci::Access::Schemeless

Perinci::Access

Riap

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Perinci-Access-Perl.

SOURCE

Source repository is at https://github.com/sharyanto/perl-Perinci-Access-Perl.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Perinci-Access-Perl

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.

AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 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.