NAME
Net::API::CPAN::Generic - Meta CPAN API Generic Class
SYNOPSIS
use Net::API::CPAN::Generic;
package Net::API::CPAN::Author;
use parent qw( Net::API::CPAN::Generic );
# ...
VERSION
v0.1.0
DESCRIPTION
Net::API::CPAN::Generic
contains some standard methods to inherit from.
METHODS
init
Initialise some default properties and return the current object.
This init
method is called by "new" in Module::Generic
api
Sets or gets the Net::API::CPAN
API object.
In scalar context, this would return undef
if none is defined yet, but in object context, this would automatically instantiate a new Net::API::CPAN
object. For example:
my $api = $obj->api; # undef
my $resp = $api->ua->get( $somewhere ); # HTTP::Promise::Response
apply
$obj->apply( key1 => $val1, key2 => $val2 );
$obj->apply({ key1 => $val1, key2 => $val2 });
This takes an hash or an hash reference of key-value pairs, and this will call the corresponding method if they exist in the object class, and set the associated value.
It returns the current object.
as_hash
my $hash_ref = $obj->as_hash;
This returns an hash reference of key-value pairs corresponding to all the object class methods.
fields
Sets or gets an array object of the package methods.
populate
This is a variation of apply. It takes an hash reference, and an optional array reference of associated properties to set their values. If no array reference is specified, it will use the object fields
methods to get the object class known properties if the fields
method is supported, otherwise, it will use all they hash reference keys as a default array reference of properties to set.
It returns the current object upon success, or, upon error, sets an error and returns undef
in scalar context, or an empty list in list context.
ERRORS
This module does not die or croak, but instead set an error object using "error" in Module::Generic and returns undef
in scalar context, or an empty list in list context.
You can retrieve the latest error object set by calling error inherited from Module::Generic
Errors issued by this distributions are all instances of class Net::API::CPAN::Exception
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
COPYRIGHT & LICENSE
Copyright(c) 2023 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.