MooX::Aliases3pm
Easy aliasing of methods and attributes in moo
Usage
package MyClass;use Moo;use MooX::Aliases;has this => (is => 'rw',alias => 'that',);sub foo { my $self = shift; print $self->that }alias bar => 'foo';my $o = MyApp->new();$o->this('Hello World');$o->bar; # prints 'Hello World'
or
package MyRole;use Moo::Role;use MooX::Aliases;has this => (is => 'rw',alias => 'that',);sub foo { my $self = shift; print $self->that }alias bar => 'foo';
Overview
The MooX::Aliases module will allow you to quickly alias methods in Moo. It provides an alias parameter for has() to generate aliased accessors as well as the standard ones. Attributes can also be initialized in the constructor via their aliased names.
You can create more than one alias at once by passing a listref:
has ip_addr => (alias => [ qw(ipAddr ip) ],);
Functions
- alias $alias, $method
-
Creates
$aliasas a method that is aliased to$method.
Caveats
This module uses the "BUILDARGS" to map the attributes. If a class uses a custom "BUILDARGS", this module may not behave properly.
Releases
5 releases since Debian 9 (Stretch); the text changed 2 times.