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: mask method: masks 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;
mask 'auth_token';
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
['auth_token', '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, masks, roles, or subs.
local(string $type) (arrayref)
{ since => '1.02', }
=example-1 local
# given: synopsis
package main;
my $attrs = $meta->local('attrs');
# ['email']
The mask method returns true or false if the package referenced has the private attribute accessor named.
mask(string $name) (boolean)
{ since => '4.15', }
=example-1 mask
# given: synopsis
package main;
my $mask = $meta->mask('auth_token');
# 1
The masks method returns all of the private attributes composed into the package referenced.
masks() (arrayref)
{ since => '4.15', }
=example-1 masks
# given: synopsis
package main;
my $masks = $meta->masks;
# ['auth_token']
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
78 POD Errors
The following errors were encountered while parsing the POD:
- Around line 14:
Unknown directive: =name
- Around line 22:
Unknown directive: =tagline
- Around line 30:
Unknown directive: =abstract
- Around line 38:
Unknown directive: =includes
- Around line 63:
Unknown directive: =synopsis
- Around line 156:
Unknown directive: =description
- Around line 165:
Unknown directive: =method
- Around line 170:
Unknown directive: =signature
- Around line 174:
Unknown directive: =metadata
- Around line 210:
=cut found outside a pod block. Skipping to next block.
- Around line 220:
Unknown directive: =method
- Around line 225:
Unknown directive: =signature
- Around line 229:
Unknown directive: =metadata
- Around line 269:
Unknown directive: =method
- Around line 274:
Unknown directive: =signature
- Around line 278:
Unknown directive: =metadata
- Around line 314:
=cut found outside a pod block. Skipping to next block.
- Around line 324:
Unknown directive: =method
- Around line 329:
Unknown directive: =signature
- Around line 333:
Unknown directive: =metadata
- Around line 367:
Unknown directive: =method
- Around line 372:
Unknown directive: =signature
- Around line 376:
Unknown directive: =metadata
- Around line 424:
Unknown directive: =method
- Around line 429:
Unknown directive: =signature
- Around line 433:
Unknown directive: =metadata
- Around line 451:
=cut found outside a pod block. Skipping to next block.
- Around line 462:
Unknown directive: =method
- Around line 469:
Unknown directive: =signature
- Around line 473:
Unknown directive: =metadata
- Around line 508:
=cut found outside a pod block. Skipping to next block.
- Around line 528:
=cut found outside a pod block. Skipping to next block.
- Around line 553:
=cut found outside a pod block. Skipping to next block.
- Around line 567:
Unknown directive: =method
- Around line 573:
Unknown directive: =signature
- Around line 577:
Unknown directive: =metadata
- Around line 613:
=cut found outside a pod block. Skipping to next block.
- Around line 633:
=cut found outside a pod block. Skipping to next block.
- Around line 667:
=cut found outside a pod block. Skipping to next block.
- Around line 693:
Unknown directive: =method
- Around line 698:
Unknown directive: =signature
- Around line 702:
Unknown directive: =metadata
- Around line 738:
=cut found outside a pod block. Skipping to next block.
- Around line 748:
Unknown directive: =method
- Around line 753:
Unknown directive: =signature
- Around line 757:
Unknown directive: =metadata
- Around line 783:
Unknown directive: =method
- Around line 788:
Unknown directive: =signature
- Around line 792:
Unknown directive: =metadata
- Around line 827:
=cut found outside a pod block. Skipping to next block.
- Around line 836:
Unknown directive: =method
- Around line 841:
Unknown directive: =signature
- Around line 845:
Unknown directive: =metadata
- Around line 873:
Unknown directive: =method
- Around line 877:
Unknown directive: =signature
- Around line 881:
Unknown directive: =metadata
- Around line 918:
=cut found outside a pod block. Skipping to next block.
- Around line 929:
Unknown directive: =method
- Around line 934:
Unknown directive: =signature
- Around line 938:
Unknown directive: =metadata
- Around line 974:
=cut found outside a pod block. Skipping to next block.
- Around line 984:
Unknown directive: =method
- Around line 988:
Unknown directive: =signature
- Around line 992:
Unknown directive: =metadata
- Around line 1021:
Unknown directive: =method
- Around line 1028:
Unknown directive: =signature
- Around line 1032:
Unknown directive: =metadata
- Around line 1067:
=cut found outside a pod block. Skipping to next block.
- Around line 1087:
=cut found outside a pod block. Skipping to next block.
- Around line 1113:
=cut found outside a pod block. Skipping to next block.
- Around line 1129:
Unknown directive: =method
- Around line 1134:
Unknown directive: =signature
- Around line 1138:
Unknown directive: =metadata
- Around line 1174:
=cut found outside a pod block. Skipping to next block.
- Around line 1184:
Unknown directive: =method
- Around line 1189:
Unknown directive: =signature
- Around line 1193:
Unknown directive: =metadata
- Around line 1247:
Unknown directive: =partials