MooX::Override - adds "override method => sub {...}" support to Moo
use v5.14; use strict; use Test::More; package Foo { use Moo; sub foo { return "foo" } } package Bar { use Moo::Role; use MooX::Override -role; override foo => sub { return uc super; }; } package Foo::Bar { use Moo; extends qw(Foo); with qw(Bar); } is( Foo::Bar->new->foo, "FOO" ); done_testing();
MooX::Override extends Moo and Moo::Role with the override method modifier, allowing you to use this Moose syntactic sugar for overriding superclass methods in Moo classes.
override
You need to indicate whether you are using this within a Moo class or a Moo role:
use MooX::Override -class; use MooX::Override -role;
See Class::Method::ModifiersX::Override for further details.
Moo, Moo::Role, Class::Method::ModifiersX::Override.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2012 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Class::Method::ModifiersX::Override, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Method::ModifiersX::Override
CPAN shell
perl -MCPAN -e shell install Class::Method::ModifiersX::Override
For more information on module installation, please visit the detailed CPAN module installation guide.