1MooseX::Types::VariantTUasbelre:C:oDnetcrliabruet(e3d)PMeorolseDXo:c:uTmyepnetsa:t:iVoanriantTable::Declare(3)
2
3
4

NAME

6       MooseX::Types::VariantTable::Declare - Declarative sugar for
7       MooseX::Types::VariantTable based methods.
8

SYNOPSIS

10           package Awesome;
11           use Moose;
12
13           variant_method dance => Item => sub {
14               # Item is the least derived type in the hierarchy,
15               # every other type subtypes it
16               # this is in effect a fallback
17               return "fallback";
18           };
19
20           # a more specific type
21           variant_method dance => Ballerina => sub {
22               my ( $self, $ballerina, @args ) = @_;
23
24               $ballerina; # a value that passed the TC named "Ballerina"
25
26               return "pretty!";
27           };
28
29           # also works with objects
30           variant_method dance => $type_object => sub { ... };
31

DESCRIPTION

33       This module provides declarative sugar for defining
34       Moose::Meta::Method::VariantTable methods in your Moose classes and
35       roles.
36
37       These methods have some semantics:
38
39   Declaration
40       The order of the declarations do not matter in most cases.
41
42       It is the type hierarchy that defines the order in which the
43       constraints are checked and items dispatched.
44
45       However, in the case that two constraints without an explicit
46       relationship between them (one is a subtype of the other) both accept
47       the same value, the one that was declared earlier will win. There is no
48       way around this issue, so be careful what types you use especially when
49       mixing variants form many different sources.
50
51       Adding the same type to a variant table twice is an error.
52
53   Inheritence
54       When dispatching all of the subclass's variants will be tried before
55       the superclass.
56
57       This allows shadowing of types from the superclass even using broader
58       types.
59
60   Roles
61       ... are currently broken.
62
63       Don't use variant table methods in a role, unless that's the only
64       definition, because in the future variant table merging will happen at
65       role composition time in a role composition like way, so your code will
66       not continue to work the same.
67

POD ERRORS

69       Hey! The above document had some coding errors, which are explained
70       below:
71
72       Around line 121:
73           =back without =over
74
75
76
77perl v5.32.1                      2021-0M1o-o2s7eX::Types::VariantTable::Declare(3)
Impressum