1MooseX::Role::WarnOnConUfsleirctC(o3n)tributed Perl DocuMmoeonsteaXt:i:oRnole::WarnOnConflict(3)
2
3
4

NAME

6       MooseX::Role::WarnOnConflict - Warn if classes override role methods
7       without excluding them
8

VERSION

10       version 0.01
11

SYNOPSIS

13       This code will warn at composition time:
14
15           {
16               package My::Role;
17               use MooseX::Role::WarnOnConflict;
18               sub conflict {}
19           }
20           {
21               package My::Class;
22               use Moose;
23               with 'My::Role';
24               sub conflict {}
25           }
26
27       With an error message similar to the following:
28
29           The class My::Class has implicitly overridden the method (conflict) from
30           role My::Role ...
31
32       To resolve this, explicitly exclude the 'conflict' method:
33
34           {
35               package My::Class;
36               use Moose;
37               with 'My::Role' => { -excludes => [ 'conflict' ] };
38               sub conflict {}
39           }
40
41       Aliasing a role method to an existing method will also warn:
42
43           {
44               package My::Class;
45               use Moose;
46               with 'My::Role' => {
47                   -excludes => ['conflict'],
48                   -alias    => { conflict => 'another_method' },
49               };
50               sub conflict       { }
51               sub another_method { }
52           }
53

DESCRIPTION

55       When using Moose::Role, a class which provides a method a role provides
56       will silently override that method.  This can cause strange, hard-to-
57       debug errors when the role's methods are not called.  Simply use
58       "MooseX::Role::WarnOnConflict" instead of "Moose::Role" and overriding
59       a role's method becomes a composition-time warning.  See the synopsis
60       for a resolution.
61

AUTHOR

63       Curtis "Ovid" Poe <curtis.poe@gmail.com>
64
66       This software is Copyright (c) 2022 by Curtis "Ovid" Poe.
67
68       This is free software, licensed under:
69
70         The Artistic License 2.0 (GPL Compatible)
71
72
73
74perl v5.34.1                      2022-06-22   MooseX::Role::WarnOnConflict(3)
Impressum