{
    "content": [
        {
            "type": "text",
            "text": "# MooseX::Role::Parameterized (perldoc)\n\n## NAME\n\nMooseX::Role::Parameterized - Moose roles with composition parameters\n\n## SYNOPSIS\n\npackage Counter;\nuse MooseX::Role::Parameterized;\nparameter name => (\nisa      => 'Str',\nrequired => 1,\n);\nrole {\nmy $p = shift;\nmy $name = $p->name;\nhas $name => (\nis      => 'rw',\nisa     => 'Int',\ndefault => 0,\n);\nmethod \"increment$name\" => sub {\nmy $self = shift;\n$self->$name($self->$name + 1);\n};\nmethod \"reset$name\" => sub {\nmy $self = shift;\n$self->$name(0);\n};\n};\npackage MyGame::Weapon;\nuse Moose;\nwith Counter => { name => 'enchantment' };\npackage MyGame::Wand;\nuse Moose;\nwith Counter => { name => 'zapped' };\n\n## DESCRIPTION\n\nYour parameterized role consists of two new things: parameter declarations and a \"role\" block.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **MooseX::Role::Parameterized::Tutorial**\n- **CAVEATS**\n- **SEE ALSO**\n- **SUPPORT**\n- **AUTHOR**\n- **CONTRIBUTORS**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "MooseX::Role::Parameterized",
        "section": "",
        "mode": "perldoc",
        "summary": "MooseX::Role::Parameterized - Moose roles with composition parameters",
        "synopsis": "package Counter;\nuse MooseX::Role::Parameterized;\nparameter name => (\nisa      => 'Str',\nrequired => 1,\n);\nrole {\nmy $p = shift;\nmy $name = $p->name;\nhas $name => (\nis      => 'rw',\nisa     => 'Int',\ndefault => 0,\n);\nmethod \"increment$name\" => sub {\nmy $self = shift;\n$self->$name($self->$name + 1);\n};\nmethod \"reset$name\" => sub {\nmy $self = shift;\n$self->$name(0);\n};\n};\npackage MyGame::Weapon;\nuse Moose;\nwith Counter => { name => 'enchantment' };\npackage MyGame::Wand;\nuse Moose;\nwith Counter => { name => 'zapped' };",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 40,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 25,
                "subsections": []
            },
            {
                "name": "MooseX::Role::Parameterized::Tutorial",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "CAVEATS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "SUPPORT",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "CONTRIBUTORS",
                "lines": 26,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "MooseX::Role::Parameterized - Moose roles with composition parameters\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version 1.11\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "package Counter;\nuse MooseX::Role::Parameterized;\n\nparameter name => (\nisa      => 'Str',\nrequired => 1,\n);\n\nrole {\nmy $p = shift;\n\nmy $name = $p->name;\n\nhas $name => (\nis      => 'rw',\nisa     => 'Int',\ndefault => 0,\n);\n\nmethod \"increment$name\" => sub {\nmy $self = shift;\n$self->$name($self->$name + 1);\n};\n\nmethod \"reset$name\" => sub {\nmy $self = shift;\n$self->$name(0);\n};\n};\n\npackage MyGame::Weapon;\nuse Moose;\n\nwith Counter => { name => 'enchantment' };\n\npackage MyGame::Wand;\nuse Moose;\n\nwith Counter => { name => 'zapped' };\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Your parameterized role consists of two new things: parameter declarations and a \"role\" block.\n\nParameters are declared using the \"parameter\" keyword which very much resembles \"has\" in Moose.\nYou can use any option that \"has\" in Moose accepts. The default value for the \"is\" option is\n\"ro\" as that's a very common case. Use \"is => 'bare'\" if you want no accessor. These parameters\nwill get their values when the consuming class (or role) uses \"with\" in Moose. A parameter\nobject will be constructed with these values, and passed to the \"role\" block.\n\nThe \"role\" block then uses the usual Moose::Role keywords to build up a role. You can shift off\nthe parameter object to inspect what the consuming class provided as parameters. You use the\nparameters to customize your role however you wish.\n\nThere are many possible implementations for parameterized roles (hopefully with a consistent\nenough API); I believe this to be the easiest and most flexible design. Coincidentally, Pugs\noriginally had an eerily similar design.\n\nSee MooseX::Role::Parameterized::Extending for some tips on how to extend this module.\n\nWhy a parameters object?\nI've been asked several times \"Why use a parameter *object* and not just a parameter *hashref*?\nThat would eliminate the need to explicitly declare your parameters.\"\n\nThe benefits of using an object are similar to the benefits of using Moose. You get an easy way\nto specify lazy defaults, type constraint, delegation, and so on. You get to use MooseX modules.\n",
                "subsections": []
            },
            "MooseX::Role::Parameterized::Tutorial": {
                "content": "Stop! If you're new here, please read MooseX::Role::Parameterized::Tutorial for a much gentler\nintroduction.\n\nYou also get the usual introspective and intercessory abilities that come standard with the\nmetaobject protocol. Ambitious users should be able to add traits to the parameters metaclass to\nfurther customize behavior. Please let me know if you're doing anything viciously complicated\nwith this extension. :)\n",
                "subsections": []
            },
            "CAVEATS": {
                "content": "You must use this syntax to declare methods in the role block: \"method NAME => sub { ... };\".\nThis is due to a limitation in Perl. In return though you can use parameters *in your methods*!\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "<http://sartak.org/2009/01/parametric-roles-in-perl-5.html>\n\n<http://sartak.org/2009/05/the-design-of-parameterized-roles.html>\n\n<http://stevan-little.blogspot.com/2009/07/thoughts-on-parameterized-roles.html>\n\n<http://perldition.org/articles/Parameterized%20Roles%20with%20MooseX::Declare.pod>\n\n<http://www.modernperlbooks.com/mt/2011/01/the-parametric-role-of-my-mvc-plugin-system.html>\n\n<http://jjnapiorkowski.typepad.com/modern-perl/2010/08/parameterized-roles-and-method-traits-red\no.html>\n\n<http://sartak.org/talks/yapc-asia-2009/(parameterized)-roles/>\n\n<https://github.com/SamuraiJack/JooseX-Role-Parameterized> - this extension ported to\nJavaScript's Joose\n",
                "subsections": []
            },
            "SUPPORT": {
                "content": "Bugs may be submitted through the RT bug tracker\n<https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Role-Parameterized> (or\nbug-MooseX-Role-Parameterized@rt.cpan.org <mailto:bug-MooseX-Role-Parameterized@rt.cpan.org>).\n\nThere is also a mailing list available for users of this distribution, at\n<http://lists.perl.org/list/moose.html>.\n\nThere is also an irc channel available for users of this distribution, at \"#moose\" on\n\"irc.perl.org\" <irc://irc.perl.org/#moose>.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Shawn M Moore <code@sartak.org>\n",
                "subsections": []
            },
            "CONTRIBUTORS": {
                "content": "*   Karen Etheridge <ether@cpan.org>\n\n*   Dave Rolsky <autarch@urth.org>\n\n*   Jesse Luehrs <doy@tozt.net>\n\n*   Oliver Charles <oliver.g.charles@googlemail.com>\n\n*   Yuval Kogman <nothingmuch@woobling.org>\n\n*   Robert 'phaylon' Sedlacek <rs@474.at>\n\n*   Florian Ragwitz <rafl@debian.org>\n\n*   Mark Fowler <mark@twoshortplanks.com>\n\n*   Chris Weyl <cweyl@alumni.drew.edu>\n\n*   Csson <erik.carlsson@live.com>\n\n*   Andy Jack <github@veracity.ca>\n\n*   Ricardo Signes <rjbs@cpan.org>\n\n*   Todd Hepler <thepler@employees.org>\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "This software is copyright (c) 2008 by Shawn M Moore.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
                "subsections": []
            }
        }
    }
}