MooX::Aliases(3pm)

πŸ“¦
version 0.001006 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute

✨ 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 $alias into 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 the BUILDARGS to map the attributes. so if a class uses a custom BUILDARGS, 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 (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