SYNOPSIS

     use Perinci::Object; # automatically exports risub(), rivar(), ripkg(),
                          # envres(), envresmulti(), riresmeta()
     use Data::Dump; # for dd()
    
     # OO interface to function metadata.
    
     my $risub = risub {
         v => 1.1,
         summary => 'Calculate foo and bar',
         "summary.alt.lang.id_ID" => 'Menghitung foo dan bar',
         args => { a1 => { schema => 'int*' }, a2 => { schema => 'str' } },
         features => { pure=>1 },
     };
     dd $risub->type,                                 # "function"
        $risub->v,                                    # 1.1
        $risub->arg('a1'),                            # { schema=>'int*' }
        $risub->arg('a3'),                            # undef
        $risub->feature('pure'),                      # 1
        $risub->feature('foo'),                       # undef
        $risub->langprop('summary'),                  # 'Calculate foo and bar'
        $risub->langprop({lang=>'id_ID'}, 'summary'), # 'Menghitung foo dan bar'
    
     # setting arg and property
     $risub->arg('a3', 'array');  # will actually fail for 1.0 metadata
     $risub->feature('foo', 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('Not found');
     $envres->result(undef);
     $envres->meta({errno=>-100});
    
     # OO interface to function/method result metadata
     my $riresmeta = riresmeta { ... };
    
     # an example of using riresmulti()
     sub myfunc {
         ...
    
         my $envres = envresmulti();
    
         # add result for each item
         $envres->add_result(200, "OK", {item_id=>1});
         $envres->add_result(202, "OK", {item_id=>2, note=>"blah"});
         $envres->add_result(404, "Not found", {item_id=>3});
         ...
    
         # finally, return the result
         return $envres->as_struct;
     }

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.

FUNCTIONS

 rimeta $meta => OBJECT

    Exported by default. A shortcut for
    Perinci::Object::Metadata->new($meta).

 risub $meta => OBJECT

    Exported by default. A shortcut for
    Perinci::Object::Function->new($meta).

 rivar $meta => OBJECT

    Exported by default. A shortcut for
    Perinci::Object::Variable->new($meta).

 ripkg $meta => OBJECT

    Exported by default. A shortcut for
    Perinci::Object::Package->new($meta).

 envres $res => OBJECT

    Exported by default. A shortcut for
    Perinci::Object::EnvResult->new($res).

 envresmulti $res => OBJECT

    Exported by default. A shortcut for
    Perinci::Object::EnvResultMulti->new($res).

 riresmeta $resmeta => OBJECT

    Exported by default. A shortcut for
    Perinci::Object::ResMeta->new($res).

SEE ALSO

    Rinci

