MooX::Aliases(3pm)
β¨ NAME β¨
okay bestie, meet MooX::Aliases β it's giving easy aliasing of methods and attributes in Moo π β¨
πΈ SYNOPSIS πΈ
bestie here's the vibe, look:
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, if you're doing the role girlie thing:
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';
π¦ DESCRIPTION π¦
so like. MooX::Aliases lets you alias methods in Moo so fast, no cap. It hands you an alias parameter for has() that generates aliased accessors on top of the standard ones β not instead of, on top of π«Ά. and the attributes can also be initialized in the constructor through their aliased names, which is lowkey the best part. β¨
and the way you can make more than one alias at once by passing a listref?? obsessed:
has ip_addr => (
alias => [ qw(ipAddr ip) ],
);
π FUNCTIONS π
alias $alias, $methodβ makes$aliasinto a method that's aliased to$method. that's it, that's the whole function, she's simple and she ate π
β οΈ CAVEATS β οΈ
okay so important: this module uses theBUILDARGSto map the attributes. so if a class uses a customBUILDARGS, this module may not behave properly. fr fr, don't come for me, that's just how it is π
π SEE ALSO π
MooseX::Aliasesβ the OG cousin, iykyk π§
π AUTHOR π
haarg β Graham Knop (cpan:HAARG) <haarg@haarg.org> π
π CONTRIBUTORS π
- Chris Prather <chris@prather.org>
- Jesse Luehrs <doy@tozt.net>
- Justin Hunter <justin.d.hunter@gmail.com>
- Karen Etheridge <ether@cpan.org>
- Yuval Kogman <nothingmuch@woobling.org>
- Daniel Gempesaw <gempesaw@gmail.com>
- Denis Ibaev <dionys@gmail.com>
π COPYRIGHT π
Copyright (c) 2013 the MooX::Alises "AUTHOR" and "CONTRIBUTORS" as listed above. π«Ά
π LICENSE π
This library is free software and may be distributed under the same terms as perl itself. slay π
and that's the whole page bestie β brought to you by perl v5.34.0, dated 2022-04-09, signing off from the MooX::Aliases(3pm) manual π
β¨
π¦ where this page comes from
- debian bookworm: libmoox-aliases-perl 0.001006-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmoox-aliases-perl 0.001006-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmoox-aliases-perl 0.001006-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmoox-aliases-perl 0.001006-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms