# MooseX::Role::Parameterized::Extending - extending MooseX::Role::Parame... - perldoc - [phpMan]

## NAME
    [MooseX::Role::Parameterized::Extending](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3ARole%3A%3AParameterized%3A%3AExtending/markdown) - extending [MooseX::Role::Parameterized](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3ARole%3A%3AParameterized/markdown) roles

## VERSION
    version 1.11

## DESCRIPTION
    There are heaps of useful modules in the "MooseX" namespace that you can use to make your roles
    more powerful. However, they do not always work out of the box with [MooseX::Role::Parameterized](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3ARole%3A%3AParameterized/markdown),
    but it's fairly straight-forward to achieve the functionality you desire.

    [MooseX::Role::Parameterized](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3ARole%3A%3AParameterized/markdown) was designed to be as extensible as the rest of Moose, and as such
    it is possible to apply custom traits to both the parameterizable role or the ordinary roles
    they generate. In this example, we will look at applying the fake trait "[MooseX::MagicRole](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3AMagicRole/markdown)" to a
    parameterizable role.

    First we need to define a new metaclass for our parameterizable role.

        package [MyApp::Meta::Role::Parameterizable](https://www.chedong.com/phpMan.php/perldoc/MyApp%3A%3AMeta%3A%3ARole%3A%3AParameterizable/markdown);
        use Moose;
        extends '[MooseX::Role::Parameterized::Meta::Role::Parameterizable](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3ARole%3A%3AParameterized%3A%3AMeta%3A%3ARole%3A%3AParameterizable/markdown)';
        with '[MooseX::MagicRole](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3AMagicRole/markdown)';

    This is a class (observe that it uses Moose, not [Moose::Role](https://www.chedong.com/phpMan.php/perldoc/Moose%3A%3ARole/markdown)) which extends the class which
    governs parameterizable roles. [MooseX::Role::Parameterized::Meta::Role::Parameterizable](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3ARole%3A%3AParameterized%3A%3AMeta%3A%3ARole%3A%3AParameterizable/markdown) is the
    metaclass that packages using [MooseX::Role::Parameterized](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3ARole%3A%3AParameterized/markdown) receive by default.

    Note that the class we are extending,
    [MooseX::Role::Parameterized::Meta::Role::Parameteriz](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3ARole%3A%3AParameterized%3A%3AMeta%3A%3ARole%3A%3AParameteriz/markdown)*able*, is entirely distinct from the
    similarly-named class which governs the ordinary roles that parameterized roles generate. An
    instance of [MooseX::Role::Parameterized::Meta::Role::Parameteriz](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3ARole%3A%3AParameterized%3A%3AMeta%3A%3ARole%3A%3AParameteriz/markdown)*ed* represents a role with its
    parameters already bound.

    Now we can take advantage of our new subclass by specifying that we want to use
    "[MyApp::Meta::Role::Parameterizable](https://www.chedong.com/phpMan.php/perldoc/MyApp%3A%3AMeta%3A%3ARole%3A%3AParameterizable/markdown)" as our metaclass when importing
    [MooseX::Role::Parameterized](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3ARole%3A%3AParameterized/markdown):

        package [MyApp::Role](https://www.chedong.com/phpMan.php/perldoc/MyApp%3A%3ARole/markdown);
        use [MooseX::Role::Parameterized](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3ARole%3A%3AParameterized/markdown) -metaclass => '[MyApp::Meta::Role::Parameterizable](https://www.chedong.com/phpMan.php/perldoc/MyApp%3A%3AMeta%3A%3ARole%3A%3AParameterizable/markdown)';

        role {
            ...
        }

    And there you go! "[MyApp::Role](https://www.chedong.com/phpMan.php/perldoc/MyApp%3A%3ARole/markdown)" now has the "[MooseX::MagicRole](https://www.chedong.com/phpMan.php/perldoc/MooseX%3A%3AMagicRole/markdown)" trait applied.

## NAME
## SUPPORT
    Bugs may be submitted through the RT bug tracker
    <<https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Role-Parameterized>> (or
    <bug-MooseX-Role-Parameterized@rt.cpan.org> <mailto:<bug-MooseX-Role-Parameterized@rt.cpan.org>>).

    There is also a mailing list available for users of this distribution, at
    <<http://lists.perl.org/list/moose.html>>.

    There is also an irc channel available for users of this distribution, at "#moose" on
    "irc.perl.org" <irc://irc.perl.org/#moose>.

## AUTHOR
    Shawn M Moore <<code@sartak.org>>

## COPYRIGHT AND LICENSE
    This software is copyright (c) 2008 by Shawn M Moore.

    This is free software; you can redistribute it and/or modify it under the same terms as the Perl
    5 programming language system itself.

