Venus::Role::Matchable
Matchable Role
Matchable Role for Perl 5
method: match
package Example;
use Venus::Class;
with 'Venus::Role::Matchable';
attr 'active';
sub validate {
my ($self) = @_;
return $self->match->when('active')->then(true)->none(false);
}
package main;
my $example = Example->new;
# $example->validate->result;
# 0
This package modifies the consuming package and provides a mechanism for assembling complex pattern matching operations.
The match method returns a Venus::Match object having the match value set to the invocant or the result of a dispatch. This method supports dispatching, i.e. providing a method name and arguments whose return value will be acted on by this method.
match(string | coderef $method, any @args) (Venus::Match)
{ since => '0.04', }
=example-1 match
package main;
my $example = Example->new;
my $match = $example->match;
# bless({..., value => bless(..., 'Example')}, 'Venus::Match')
t/Venus.t: present: authors t/Venus.t: present: license
12 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 46:
Unknown directive: =synopsis
- Around line 82:
Unknown directive: =description
- Around line 91:
Unknown directive: =method
- Around line 98:
Unknown directive: =signature
- Around line 102:
Unknown directive: =metadata
- Around line 139:
=cut found outside a pod block. Skipping to next block.
- Around line 160:
=cut found outside a pod block. Skipping to next block.
- Around line 171:
Unknown directive: =partials