{
    "content": [
        {
            "type": "text",
            "text": "# Moose::Cookbook::Basics::Document_AugmentAndInner (perldoc)\n\n## NAME\n\nMoose::Cookbook::Basics::DocumentAugmentAndInner - The augment modifier, which turns normal method overriding \"inside-out\"\n\n## SYNOPSIS\n\npackage Document::Page;\nuse Moose;\nhas 'body' => ( is => 'rw', isa => 'Str', default => sub {''} );\nsub create {\nmy $self = shift;\n$self->openpage;\ninner();\n$self->closepage;\n}\nsub appendbody {\nmy ( $self, $appendage ) = @;\n$self->body( $self->body . $appendage );\n}\nsub openpage  { (shift)->appendbody('<page>') }\nsub closepage { (shift)->appendbody('</page>') }\npackage Document::PageWithHeadersAndFooters;\nuse Moose;\nextends 'Document::Page';\naugment 'create' => sub {\nmy $self = shift;\n$self->createheader;\ninner();\n$self->createfooter;\n};\nsub createheader { (shift)->appendbody('<header/>') }\nsub createfooter { (shift)->appendbody('<footer/>') }\npackage TPSReport;\nuse Moose;\nextends 'Document::PageWithHeadersAndFooters';\naugment 'create' => sub {\nmy $self = shift;\n$self->createtpsreport;\ninner();\n};\nsub createtpsreport {\n(shift)->appendbody('<report type=\"tps\"/>');\n}\n# <page><header/><report type=\"tps\"/><footer/></page>\nmy $reportxml = TPSReport->new->create;\n\n## DESCRIPTION\n\nThis recipe shows how the \"augment\" method modifier works. This modifier reverses the normal\nsubclass to parent method resolution order. With an \"augment\" modifier the *least* specific\nmethod is called first. Each successive call to \"inner\" descends the inheritance tree, ending at\nthe most specific subclass.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **CONCLUSION**\n- **AUTHORS**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Moose::Cookbook::Basics::Document_AugmentAndInner",
        "section": "",
        "mode": "perldoc",
        "summary": "Moose::Cookbook::Basics::DocumentAugmentAndInner - The augment modifier, which turns normal method overriding \"inside-out\"",
        "synopsis": "package Document::Page;\nuse Moose;\nhas 'body' => ( is => 'rw', isa => 'Str', default => sub {''} );\nsub create {\nmy $self = shift;\n$self->openpage;\ninner();\n$self->closepage;\n}\nsub appendbody {\nmy ( $self, $appendage ) = @;\n$self->body( $self->body . $appendage );\n}\nsub openpage  { (shift)->appendbody('<page>') }\nsub closepage { (shift)->appendbody('</page>') }\npackage Document::PageWithHeadersAndFooters;\nuse Moose;\nextends 'Document::Page';\naugment 'create' => sub {\nmy $self = shift;\n$self->createheader;\ninner();\n$self->createfooter;\n};\nsub createheader { (shift)->appendbody('<header/>') }\nsub createfooter { (shift)->appendbody('<footer/>') }\npackage TPSReport;\nuse Moose;\nextends 'Document::PageWithHeadersAndFooters';\naugment 'create' => sub {\nmy $self = shift;\n$self->createtpsreport;\ninner();\n};\nsub createtpsreport {\n(shift)->appendbody('<report type=\"tps\"/>');\n}\n# <page><header/><report type=\"tps\"/><footer/></page>\nmy $reportxml = TPSReport->new->create;",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 53,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 45,
                "subsections": []
            },
            {
                "name": "CONCLUSION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 20,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Moose::Cookbook::Basics::DocumentAugmentAndInner - The augment modifier, which turns normal\nmethod overriding \"inside-out\"\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version 2.2200\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "package Document::Page;\nuse Moose;\n\nhas 'body' => ( is => 'rw', isa => 'Str', default => sub {''} );\n\nsub create {\nmy $self = shift;\n$self->openpage;\ninner();\n$self->closepage;\n}\n\nsub appendbody {\nmy ( $self, $appendage ) = @;\n$self->body( $self->body . $appendage );\n}\n\nsub openpage  { (shift)->appendbody('<page>') }\nsub closepage { (shift)->appendbody('</page>') }\n\npackage Document::PageWithHeadersAndFooters;\nuse Moose;\n\nextends 'Document::Page';\n\naugment 'create' => sub {\nmy $self = shift;\n$self->createheader;\ninner();\n$self->createfooter;\n};\n\nsub createheader { (shift)->appendbody('<header/>') }\nsub createfooter { (shift)->appendbody('<footer/>') }\n\npackage TPSReport;\nuse Moose;\n\nextends 'Document::PageWithHeadersAndFooters';\n\naugment 'create' => sub {\nmy $self = shift;\n$self->createtpsreport;\ninner();\n};\n\nsub createtpsreport {\n(shift)->appendbody('<report type=\"tps\"/>');\n}\n\n# <page><header/><report type=\"tps\"/><footer/></page>\nmy $reportxml = TPSReport->new->create;\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This recipe shows how the \"augment\" method modifier works. This modifier reverses the normal\nsubclass to parent method resolution order. With an \"augment\" modifier the *least* specific\nmethod is called first. Each successive call to \"inner\" descends the inheritance tree, ending at\nthe most specific subclass.\n\nThe \"augment\" modifier lets you design a parent class that can be extended in a specific way.\nThe parent provides generic wrapper functionality, and the subclasses fill in the details.\n\nIn the example above, we've created a set of document classes, with the most specific being the\n\"TPSReport\" class.\n\nWe start with the least specific class, \"Document::Page\". Its create method contains a call to\n\"inner()\":\n\nsub create {\nmy $self = shift;\n$self->openpage;\ninner();\n$self->closepage;\n}\n\nThe \"inner\" function is exported by \"Moose\", and is like \"super\" for augmented methods. When\n\"inner\" is called, Moose finds the next method in the chain, which is the \"augment\" modifier in\n\"Document::PageWithHeadersAndFooters\". You'll note that we can call \"inner\" in our modifier:\n\naugment 'create' => sub {\nmy $self = shift;\n$self->createheader;\ninner();\n$self->createfooter;\n};\n\nThis finds the next most specific modifier, in the \"TPSReport\" class.\n\nFinally, in the \"TPSReport\" class, the chain comes to an end:\n\naugment 'create' => sub {\nmy $self = shift;\n$self->createtpsreport;\ninner();\n};\n\nWe do call the \"inner\" function one more time, but since there is no more specific subclass,\nthis is a no-op. Making this call means we can easily subclass \"TPSReport\" in the future.\n",
                "subsections": []
            },
            "CONCLUSION": {
                "content": "The \"augment\" modifier is a powerful tool for creating a set of nested wrappers. It's not\nsomething you will need often, but when you do, it is very handy.\n",
                "subsections": []
            },
            "AUTHORS": {
                "content": "*   Stevan Little <stevan@cpan.org>\n\n*   Dave Rolsky <autarch@urth.org>\n\n*   Jesse Luehrs <doy@cpan.org>\n\n*   Shawn M Moore <sartak@cpan.org>\n\n*   יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>\n\n*   Karen Etheridge <ether@cpan.org>\n\n*   Florian Ragwitz <rafl@debian.org>\n\n*   Hans Dieter Pearcey <hdp@cpan.org>\n\n*   Chris Prather <chris@prather.org>\n\n*   Matt S Trout <mstrout@cpan.org>\n",
                "subsections": []
            },
            "COPYRIGHT AND LICENSE": {
                "content": "This software is copyright (c) 2006 by Infinity Interactive, Inc.\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": []
            }
        }
    }
}