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(Str | CodeRef $method, Any @args) (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: pdml: authors t/Venus.t: pdml: license

12 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 45:

Unknown directive: =synopsis

Around line 81:

Unknown directive: =description

Around line 90:

Unknown directive: =method

Around line 97:

Unknown directive: =signature

Around line 101:

Unknown directive: =metadata

Around line 138:

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

Around line 159:

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

Around line 170:

Unknown directive: =partials