Scroll to navigation

MooseX::Aliases(3pm) User Contributed Perl Documentation MooseX::Aliases(3pm)

NAME

MooseX::Aliases - easy aliasing of methods and attributes in Moose

VERSION

version 0.10

SYNOPSIS

    package MyApp;
    use Moose;
    use MooseX::Aliases;
    has this => (
        isa   => 'Str',
        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 MyApp::Role;
    use Moose::Role;
    use MooseX::Aliases;
    has this => (
        isa   => 'Str',
        is    => 'rw',
        alias => 'that',
    );
    sub foo { my $self = shift; print $self->that }
    alias bar => 'foo';

DESCRIPTION

The MooseX::Aliases module will allow you to quickly alias methods in Moose. 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 METHODNAME

Installs ALIAS as a method that is aliased to the method METHODNAME.

CAVEATS

The order of arguments for the "alias" method has changed (as of version 0.05). I think the new order makes more sense, and it will make future refactoring I have in mind easier. The old order still works (although it gives a deprecation warning), unless you were relying on being able to override an existing method with an alias - this will now override in the other direction. The old argument order will be removed in a future release.

BUGS

No known bugs.
Please report any bugs through RT: email "bug-moosex-aliases at rt.cpan.org", or browse to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-Aliases <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooseX-Aliases>.

SEE ALSO

Moose
Method::Alias

SUPPORT

You can find this documentation for this module with the perldoc command.
    perldoc MooseX::Aliases
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
 
http://annocpan.org/dist/MooseX-Aliases <http://annocpan.org/dist/MooseX-Aliases>
CPAN Ratings
 
http://cpanratings.perl.org/d/MooseX-Aliases <http://cpanratings.perl.org/d/MooseX-Aliases>
RT: CPAN's request tracker
 
http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Aliases <http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Aliases>
Search CPAN
 
http://search.cpan.org/dist/MooseX-Aliases <http://search.cpan.org/dist/MooseX-Aliases>

AUTHORS

Jesse Luehrs <doy at tozt dot net>
Chris Prather <chris@prather.org>
Justin Hunter <justin.d.hunter at gmail dot com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Jesse Luehrs.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2011-04-29 perl v5.12.3