Perl Diver 2.33
Main Environment Variables Perl Default Values Perl Config - Summary Perl Config - Full Installed Modules List Directory uptime Docs

Module Documentation
Details and documentation about a specific module, including version and documentation (if available). Note that while links to perldoc.com and search.cpan.org are provided, the module may be part of a larger distribution. If you reach a File Not Found page on either site, please try the parent module.

MooX::Aliases

Name MooX::Aliases
Version 0.001006
Located at /usr/share/perl5
File /usr/share/perl5/MooX/Aliases.pm
Is Core No
Search CPAN for this module MooX::Aliases
Documentation MooX::Aliases
Module Details MooX::Aliases

NAME

MooX::Aliases - easy aliasing of methods and attributes in Moo


SYNOPSIS

  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';


DESCRIPTION

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 $alias as 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.


SEE ALSO

MooseX::Aliases


AUTHOR

haarg - Graham Knop (cpan:HAARG) <haarg@haarg.org>

CONTRIBUTORS


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.

Perl Diver brought to you by ScriptSolutions.com © 1997- 2026