GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  MOOSEX::ALIASES (3)

.ds Aq ’

NAME

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

CONTENTS

VERSION

version 0.11

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 arrayref:



    has ip_addr => (
        alias => [ qw(ipAddr ip) ],
    );



FUNCTIONS

    alias ALIAS METHODNAME

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

ALIASING VERSUS OTHER MOOSE FEATURES

    Aliasing versus inheritance



    {
        package Parent;
        use Moose;
        use MooseX::Aliases;
        sub method1 { "A" }
        alias method2 => "method1";
    }

    {
        package Child1;
        use Moose;
        extends "Parent";
        sub method1 { "B" }
    }

    {
        package Child2;
        use Moose;
        extends "Parent";
        sub method2 { "C" }
    }



In the example above, Child1 overrides the method using its original name (method1). As a result, calling method1 or method2 returns B. Child2 overrides the method using its alias (method2). As a result, calling method2 returns C, but calling method1 falls through to the parent class, so returns A.

    Aliasing versus method modifiers



    {
        package Class1;
        use Moose;
        use MooseX::Aliases;
        sub method1 { "A" }
        alias method2 => "method1";
        around method1 => sub { "B" };
    }

    {
        package Class2;
        use Moose;
        use MooseX::Aliases;
        sub method1 { "A" }
        alias method2 => "method1";
        around method2 => sub { "B" };
    }



In the example above, Class1’s around modifier modifies the method using its original name. As a result, both method1 and method2 return B. Class2’s around modifier modifies the alias, so method2 returns B, but method1 continues to return A.

BUGS

No known bugs.

Please report any bugs to GitHub Issues at <https://github.com/doy/moosex-aliases/issues>.

SEE ALSO

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:
o MetaCPAN

<https://metacpan.org/release/MooseX-Aliases>

o Github

<https://github.com/doy/moosex-aliases>

o RT: CPAN’s request tracker

<http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooseX-Aliases>

o CPAN Ratings

<http://cpanratings.perl.org/d/MooseX-Aliases>

AUTHORS

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

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 MOOSEX::ALIASES (3) 2013-07-12

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.