NAME
MooX::Augment - adds "augment method => sub {...}" support to Moo
SYNOPSIS
use v5.14;
use strict;
use Test::More;
package Document {
use Moo;
use MooX::Augment -class;
has recipient => (is => 'ro');
sub as_xml { sprintf "<document>%s</document>", inner }
}
package Greeting {
use Moo;
use MooX::Augment -class;
extends qw( Document );
augment as_xml => sub {
sprintf "<greet>%s</greet>", inner
}
}
package Greeting::English {
use Moo;
use MooX::Augment -class;
extends qw( Greeting );
augment as_xml => sub {
my $self = shift;
sprintf "Hello %s", $self->recipient;
}
}
my $obj = Greeting::English->new(recipient => "World");
is(
$obj->as_xml,
"<document><greet>Hello World</greet></document>",
);
done_testing();
DESCRIPTION
MooX::Augment extends Moo with the augment
method modifier, allowing you to use this Moose abomination for augmenting superclass methods in Moo classes.
You need to indicate whether you are using this within a Moo class or a Moo role:
use MooX::Augment -class;
use MooX::Augment -role;
Note that Moo roles cannot provide augment
method modifiers. Roles may import inner
though it has not been thoroughly tested and may be of limited utility.
See Class::Method::ModifiersX::Augment for further details.
SEE ALSO
Moo, Class::Method::ModifiersX::Augment.
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
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.
DISCLAIMER OF WARRANTIES
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.