GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
MooseX::Role::WarnOnConflict(3) User Contributed Perl Documentation MooseX::Role::WarnOnConflict(3)

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

version 0.01

This code will warn at composition time:

    {
        package My::Role;
        use MooseX::Role::WarnOnConflict;
        sub conflict {}
    }
    {
        package My::Class;
        use Moose;
        with 'My::Role';
        sub conflict {}
    }

With an error message similar to the following:

    The class My::Class has implicitly overridden the method (conflict) from
    role My::Role ...

To resolve this, explicitly exclude the 'conflict' method:

    {
        package My::Class;
        use Moose;
        with 'My::Role' => { -excludes => [ 'conflict' ] };
        sub conflict {}
    }

Aliasing a role method to an existing method will also warn:

    {
        package My::Class;
        use Moose;
        with 'My::Role' => {
            -excludes => ['conflict'],
            -alias    => { conflict => 'another_method' },
        };
        sub conflict       { }
        sub another_method { }
    }

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

Curtis "Ovid" Poe <curtis.poe@gmail.com>

This software is Copyright (c) 2022 by Curtis "Ovid" Poe.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)
2022-05-21 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.