Venus::Meta
Class Metadata
Class Metadata for Perl 5
method: attr method: attrs method: base method: bases method: data method: emit method: find method: local method: mixin method: mixins method: new method: role method: roles method: search method: sub method: subs
package Person;
use Venus::Class;
attr 'fname';
attr 'lname';
package Identity;
use Venus::Role;
attr 'id';
attr 'login';
attr 'password';
sub EXPORT {
# explicitly declare routines to be consumed
['id', 'login', 'password']
}
package Authenticable;
use Venus::Role;
sub authenticate {
return true;
}
sub AUDIT {
my ($self, $from) = @_;
# ensure the caller has a login and password when consumed
die "${from} missing the login attribute" if !$from->can('login');
die "${from} missing the password attribute" if !$from->can('password');
}
sub EXPORT {
# explicitly declare routines to be consumed
['authenticate']
}
package Novice;
use Venus::Mixin;
sub points {
100
}
package User;
use Venus::Class 'attr', 'base', 'mixin', 'test', 'with';
base 'Person';
with 'Identity';
mixin 'Novice';
attr 'email';
test 'Authenticable';
sub valid {
my ($self) = @_;
return $self->login && $self->password ? true : false;
}
package main;
my $user = User->new(
fname => 'Elliot',
lname => 'Alderson',
);
my $meta = $user->meta;
# bless({name => 'User'}, 'Venus::Meta')
This package provides configuration information for Venus derived classes, roles, and interfaces.
The attr method returns true or false if the package referenced has the attribute accessor named.
attr(string $name) (boolean)
{ since => '1.00', }
=example-1 attr
# given: synopsis
package main;
my $attr = $meta->attr('email');
# 1
The attrs method returns all of the attributes composed into the package referenced.
attrs() (arrayref)
{ since => '1.00', }
=example-1 attrs
# given: synopsis
package main;
my $attrs = $meta->attrs;
# [
# 'email',
# 'fname',
# 'id',
# 'lname',
# 'login',
# 'password',
# ]
The base method returns true or false if the package referenced has inherited the package named.
base(string $name) (boolean)
{ since => '1.00', }
=example-1 base
# given: synopsis
package main;
my $base = $meta->base('Person');
# 1
The bases method returns returns all of the packages inherited by the package referenced.
bases() (arrayref)
{ since => '1.00', }
=example-1 bases
# given: synopsis
package main;
my $bases = $meta->bases;
# [
# 'Person',
# 'Venus::Core::Class',
# 'Venus::Core',
# ]
The data method returns a data structure representing the shallow configuration for the package referenced.
data() (hashref)
{ since => '1.00', }
=example-1 data
# given: synopsis
package main;
my $data = $meta->data;
# {
# 'ATTR' => {
# 'email' => [
# 'email'
# ]
# },
# 'BASE' => {
# 'Person' => [
# 'Person'
# ]
# },
# 'ROLE' => {
# 'Authenticable' => [
# 'Authenticable'
# ],
# 'Identity' => [
# 'Identity'
# ]
# }
# }
The emit method invokes the lifecycle hook specified on the underlying package and returns the result.
emit(string $name, any @args) (any)
{ since => '2.91', }
The find method finds and returns the first configuration for the property type specified. This method uses the "search" method to search roles, bases, mixins, and the source package, in the order listed. The "property type" can be any one of attr, base, mixin, or role.
find(string $type, string $name) (tuple[string,tuple[number,arrayref]])
{ since => '1.02', }
=example-1 find
# given: synopsis
package main;
my $find = $meta->find;
# ()
The local method returns the names of properties defined in the package directly (not inherited) for the property type specified. The $type provided can be either attrs, bases, roles, or subs.
local(string $type) (arrayref)
{ since => '1.02', }
=example-1 local
# given: synopsis
package main;
my $attrs = $meta->local('attrs');
# ['email']
The mixin method returns true or false if the package referenced has consumed the mixin named.
mixin(string $name) (boolean)
{ since => '1.02', }
=example-1 mixin
# given: synopsis
package main;
my $mixin = $meta->mixin('Novice');
# 1
The mixins method returns all of the mixins composed into the package referenced.
mixins() (arrayref)
{ since => '1.02', }
=example-1 mixins
# given: synopsis
package main;
my $mixins = $meta->mixins;
# [
# 'Novice',
# ]
The new method returns a new instance of this package.
new(any %args | hashref $args) (object)
{ since => '1.00', }
=example-1 new
# given: synopsis
package main;
$meta = Venus::Meta->new(name => 'User');
# bless({name => 'User'}, 'Venus::Meta')
The role method returns true or false if the package referenced has consumed the role named.
role(string $name) (boolean)
{ since => '1.00', }
=example-1 role
# given: synopsis
package main;
my $role = $meta->role('Identity');
# 1
The roles method returns all of the roles composed into the package referenced.
roles() (arrayref)
{ since => '1.00', }
=example-1 roles
# given: synopsis
package main;
my $roles = $meta->roles;
# [
# 'Identity',
# 'Authenticable'
# ]
The search method searches the source specified and returns the configurations for the property type specified. The source can be any one of bases, roles, mixins, or self for the source package. The "property type" can be any one of attr, base, mixin, or role.
search(string $from, string $type, string $name) (within[arrayref, tuple[string,tuple[number,arrayref]]])
{ since => '1.02', }
=example-1 search
# given: synopsis
package main;
my $search = $meta->search;
# ()
The sub method returns true or false if the package referenced has the subroutine named on the package directly, or any of its superclasses.
sub(string $name) (boolean)
{ since => '1.00', }
=example-1 sub
# given: synopsis
package main;
my $sub = $meta->sub('authenticate');
# 1
The subs method returns all of the subroutines composed into the package referenced.
subs() (arrayref)
{ since => '1.00', }
=example-1 subs
# given: synopsis
package main;
my $subs = $meta->subs;
# [
# 'attr', ...,
# 'base',
# 'email',
# 'false',
# 'fname', ...,
# 'id',
# 'lname',
# 'login',
# 'new', ...,
# 'role',
# 'test',
# 'true',
# 'with', ...,
# ]
t/Venus.t: present: authors t/Venus.t: present: license
71 POD Errors
The following errors were encountered while parsing the POD:
- Around line 13:
Unknown directive: =name
- Around line 21:
Unknown directive: =tagline
- Around line 29:
Unknown directive: =abstract
- Around line 37:
Unknown directive: =includes
- Around line 60:
Unknown directive: =synopsis
- Around line 151:
Unknown directive: =description
- Around line 160:
Unknown directive: =method
- Around line 165:
Unknown directive: =signature
- Around line 169:
Unknown directive: =metadata
- Around line 205:
=cut found outside a pod block. Skipping to next block.
- Around line 215:
Unknown directive: =method
- Around line 220:
Unknown directive: =signature
- Around line 224:
Unknown directive: =metadata
- Around line 264:
Unknown directive: =method
- Around line 269:
Unknown directive: =signature
- Around line 273:
Unknown directive: =metadata
- Around line 309:
=cut found outside a pod block. Skipping to next block.
- Around line 319:
Unknown directive: =method
- Around line 324:
Unknown directive: =signature
- Around line 328:
Unknown directive: =metadata
- Around line 362:
Unknown directive: =method
- Around line 367:
Unknown directive: =signature
- Around line 371:
Unknown directive: =metadata
- Around line 419:
Unknown directive: =method
- Around line 424:
Unknown directive: =signature
- Around line 428:
Unknown directive: =metadata
- Around line 446:
=cut found outside a pod block. Skipping to next block.
- Around line 457:
Unknown directive: =method
- Around line 464:
Unknown directive: =signature
- Around line 468:
Unknown directive: =metadata
- Around line 503:
=cut found outside a pod block. Skipping to next block.
- Around line 523:
=cut found outside a pod block. Skipping to next block.
- Around line 548:
=cut found outside a pod block. Skipping to next block.
- Around line 562:
Unknown directive: =method
- Around line 568:
Unknown directive: =signature
- Around line 572:
Unknown directive: =metadata
- Around line 608:
=cut found outside a pod block. Skipping to next block.
- Around line 628:
=cut found outside a pod block. Skipping to next block.
- Around line 661:
=cut found outside a pod block. Skipping to next block.
- Around line 686:
Unknown directive: =method
- Around line 691:
Unknown directive: =signature
- Around line 695:
Unknown directive: =metadata
- Around line 730:
=cut found outside a pod block. Skipping to next block.
- Around line 739:
Unknown directive: =method
- Around line 744:
Unknown directive: =signature
- Around line 748:
Unknown directive: =metadata
- Around line 776:
Unknown directive: =method
- Around line 780:
Unknown directive: =signature
- Around line 784:
Unknown directive: =metadata
- Around line 821:
=cut found outside a pod block. Skipping to next block.
- Around line 832:
Unknown directive: =method
- Around line 837:
Unknown directive: =signature
- Around line 841:
Unknown directive: =metadata
- Around line 877:
=cut found outside a pod block. Skipping to next block.
- Around line 887:
Unknown directive: =method
- Around line 891:
Unknown directive: =signature
- Around line 895:
Unknown directive: =metadata
- Around line 924:
Unknown directive: =method
- Around line 931:
Unknown directive: =signature
- Around line 935:
Unknown directive: =metadata
- Around line 970:
=cut found outside a pod block. Skipping to next block.
- Around line 990:
=cut found outside a pod block. Skipping to next block.
- Around line 1016:
=cut found outside a pod block. Skipping to next block.
- Around line 1032:
Unknown directive: =method
- Around line 1037:
Unknown directive: =signature
- Around line 1041:
Unknown directive: =metadata
- Around line 1077:
=cut found outside a pod block. Skipping to next block.
- Around line 1087:
Unknown directive: =method
- Around line 1092:
Unknown directive: =signature
- Around line 1096:
Unknown directive: =metadata
- Around line 1150:
Unknown directive: =partials