{
    "content": [
        {
            "type": "text",
            "text": "# Moose::Manual::Classes (perldoc)\n\n## NAME\n\nMoose::Manual::Classes - Making your classes use Moose (and subclassing)\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **USING MOOSE**\n- **SUBCLASSING**\n- **CLEANING UP MOOSE DROPPINGS**\n- **MAKING IT FASTER**\n- **INSTANTIATING CLASSES**\n- **AUTHORS**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Moose::Manual::Classes",
        "section": "",
        "mode": "perldoc",
        "summary": "Moose::Manual::Classes - Making your classes use Moose (and subclassing)",
        "synopsis": null,
        "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": "USING MOOSE",
                "lines": 39,
                "subsections": []
            },
            {
                "name": "SUBCLASSING",
                "lines": 23,
                "subsections": []
            },
            {
                "name": "CLEANING UP MOOSE DROPPINGS",
                "lines": 23,
                "subsections": []
            },
            {
                "name": "MAKING IT FASTER",
                "lines": 21,
                "subsections": []
            },
            {
                "name": "INSTANTIATING CLASSES",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "AUTHORS",
                "lines": 20,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Moose::Manual::Classes - Making your classes use Moose (and subclassing)\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version 2.2200\n",
                "subsections": []
            },
            "USING MOOSE": {
                "content": "Using Moose is very simple, you just \"use Moose\":\n\npackage Person;\n\nuse Moose;\n\nThat's it, you've made a class with Moose!\n\nThere's actually a lot going on here under the hood, so let's step through it.\n\nWhen you load Moose, a bunch of sugar functions are exported into your class, such as \"extends\",\n\"has\", \"with\", and more. These functions are what you use to define your class. For example, you\nmight define an attribute ...\n\npackage Person;\n\nuse Moose;\n\nhas 'ssn' => ( is => 'rw' );\n\nAttributes are described in the Moose::Manual::Attributes documentation.\n\nLoading Moose also enables the \"strict\" and \"warnings\" pragmas in your class.\n\nWhen you load Moose, your class will become a subclass of Moose::Object. The Moose::Object class\nprovides a default constructor and destructor, as well as object construction helper methods.\nYou can read more about this in the Moose::Manual::Construction document.\n\nAs a convenience, Moose creates a new class type for your class. See the Moose::Manual::Types\ndocument to learn more about types.\n\nIt also creates a Moose::Meta::Class object for your class. This metaclass object is now\navailable by calling a \"meta\" method on your class, for example \"Person->meta\".\n\nThe metaclass object provides an introspection API for your class. It is also used by Moose\nitself under the hood to add attributes, define parent classes, and so on. In fact, all of\nMoose's sugar does the real work by calling methods on this metaclass object (and other meta API\nobjects).\n",
                "subsections": []
            },
            "SUBCLASSING": {
                "content": "Moose provides a simple sugar function for declaring your parent classes, \"extends\":\n\npackage User;\n\nuse Moose;\n\nextends 'Person';\n\nhas 'username' => ( is => 'rw' );\n\nNote that each call to \"extends\" will *reset* your parents. For multiple inheritance you must\nprovide all the parents at once, \"extends 'Foo', 'Bar'\".\n\nWhen you call \"extends\" Moose will try to load any classes you pass.\n\nYou can use Moose to extend a non-Moose parent. However, when you do this, you will inherit the\nparent class's constructor (assuming it is also called \"new\"). In that case, you will have to\ntake care of initializing attributes manually, either in the parent's constructor, or in your\nsubclass, and you will lose a lot of Moose magic.\n\nSee the MooseX::NonMoose module on CPAN if you're interested in extending non-Moose parent\nclasses with Moose child classes.\n",
                "subsections": []
            },
            "CLEANING UP MOOSE DROPPINGS": {
                "content": "Moose exports a number of functions into your class. It's a good idea to remove these sugar\nfunctions from your class's namespace, so that \"Person->can('has')\" will no longer return true.\n\nThere are several ways to do this. We recommend using namespace::autoclean, a CPAN module. Not\nonly will it remove Moose exports, it will also remove any other exports.\n\npackage Person;\n\nuse namespace::autoclean;\n\nuse Moose;\n\nIf you absolutely can't use a CPAN module (but can use Moose?), you can write \"no Moose\" at the\nend of your class. This will remove any Moose exports in your class.\n\npackage Person;\n\nuse Moose;\n\nhas 'ssn' => ( is => 'rw' );\n\nno Moose;\n",
                "subsections": []
            },
            "MAKING IT FASTER": {
                "content": "Moose has a feature called \"immutabilization\" that you can use to greatly speed up your classes\nat runtime. However, using it incurs a cost when your class is first being loaded. When you make\nyour class immutable you tell Moose that you will not be changing it in the future. You will not\nbe adding any more attributes, methods, roles, etc.\n\nThis allows Moose to generate code specific to your class. In particular, it creates an \"inline\"\nconstructor, making object construction much faster.\n\nTo make your class immutable you simply call \"makeimmutable\" on your class's metaclass object.\n\nPACKAGE->meta->makeimmutable;\n\nImmutabilization and \"new()\"\nIf you override \"new()\" in your class, then the immutabilization code will not be able to\nprovide an optimized constructor for your class. Instead, you should use a \"BUILD()\" method,\nwhich will be called from the inlined constructor.\n\nAlternately, if you really need to provide a different \"new()\", you can also provide your own\nimmutabilization method. Doing so requires extending the Moose metaclasses, and is well beyond\nthe scope of this manual.\n",
                "subsections": []
            },
            "INSTANTIATING CLASSES": {
                "content": "When you're ready to use Moose classes in an application, reference them in your code in the\nregular Perl OO way by including a \"use\" directive at the top of the file where the objects\nshould be created.\n\nuse Person;\n\nmy $person = Person->new(\n# attribute values at instantiation\n# go here\nssn => '123456789',\n);\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": []
            }
        }
    }
}