Venus::Meta

Class Metadata

Class Metadata for Perl 5

method: attr method: attrs method: base method: bases method: data 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(Str $name) (Bool)

{ 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(Str $name) (Bool)

{ 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 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(Str $type, Str $name) (Tuple[Str,Tuple[Int,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(Str $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(Str $name) (Bool)

{ 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(Str $name) (Bool)

{ 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(Str $from, Str $type, Str $name) (ArrayRef[Tuple[Str,Tuple[Int,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(Str $name) (Bool)

{ 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: pdml: authors t/Venus.t: pdml: license

67 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 59:

Unknown directive: =synopsis

Around line 150:

Unknown directive: =description

Around line 159:

Unknown directive: =method

Around line 164:

Unknown directive: =signature

Around line 168:

Unknown directive: =metadata

Around line 204:

=cut found outside a pod block. Skipping to next block.

Around line 214:

Unknown directive: =method

Around line 219:

Unknown directive: =signature

Around line 223:

Unknown directive: =metadata

Around line 263:

Unknown directive: =method

Around line 268:

Unknown directive: =signature

Around line 272:

Unknown directive: =metadata

Around line 308:

=cut found outside a pod block. Skipping to next block.

Around line 318:

Unknown directive: =method

Around line 323:

Unknown directive: =signature

Around line 327:

Unknown directive: =metadata

Around line 361:

Unknown directive: =method

Around line 366:

Unknown directive: =signature

Around line 370:

Unknown directive: =metadata

Around line 418:

Unknown directive: =method

Around line 425:

Unknown directive: =signature

Around line 429:

Unknown directive: =metadata

Around line 464:

=cut found outside a pod block. Skipping to next block.

Around line 484:

=cut found outside a pod block. Skipping to next block.

Around line 509:

=cut found outside a pod block. Skipping to next block.

Around line 523:

Unknown directive: =method

Around line 529:

Unknown directive: =signature

Around line 533:

Unknown directive: =metadata

Around line 569:

=cut found outside a pod block. Skipping to next block.

Around line 589:

=cut found outside a pod block. Skipping to next block.

Around line 622:

=cut found outside a pod block. Skipping to next block.

Around line 646:

Unknown directive: =method

Around line 651:

Unknown directive: =signature

Around line 655:

Unknown directive: =metadata

Around line 690:

=cut found outside a pod block. Skipping to next block.

Around line 699:

Unknown directive: =method

Around line 704:

Unknown directive: =signature

Around line 708:

Unknown directive: =metadata

Around line 736:

Unknown directive: =method

Around line 740:

Unknown directive: =signature

Around line 744:

Unknown directive: =metadata

Around line 781:

=cut found outside a pod block. Skipping to next block.

Around line 792:

Unknown directive: =method

Around line 797:

Unknown directive: =signature

Around line 801:

Unknown directive: =metadata

Around line 837:

=cut found outside a pod block. Skipping to next block.

Around line 847:

Unknown directive: =method

Around line 851:

Unknown directive: =signature

Around line 855:

Unknown directive: =metadata

Around line 884:

Unknown directive: =method

Around line 891:

Unknown directive: =signature

Around line 895:

Unknown directive: =metadata

Around line 930:

=cut found outside a pod block. Skipping to next block.

Around line 950:

=cut found outside a pod block. Skipping to next block.

Around line 976:

=cut found outside a pod block. Skipping to next block.

Around line 992:

Unknown directive: =method

Around line 997:

Unknown directive: =signature

Around line 1001:

Unknown directive: =metadata

Around line 1037:

=cut found outside a pod block. Skipping to next block.

Around line 1047:

Unknown directive: =method

Around line 1052:

Unknown directive: =signature

Around line 1056:

Unknown directive: =metadata

Around line 1110:

Unknown directive: =partials