{
    "content": [
        {
            "type": "text",
            "text": "# Class::MOP::Instance (perldoc)\n\n## NAME\n\nClass::MOP::Instance - Instance Meta Object\n\n## DESCRIPTION\n\nThe Instance Protocol controls the creation of object instances, and the storage of attribute\nvalues in those instances.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **DESCRIPTION**\n- **METHODS** (6 subsections)\n- **AUTHORS**\n- **COPYRIGHT AND LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Class::MOP::Instance",
        "section": "",
        "mode": "perldoc",
        "summary": "Class::MOP::Instance - Instance Meta Object",
        "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": "DESCRIPTION",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Object construction",
                        "lines": 14
                    },
                    {
                        "name": "Creating and altering instances",
                        "lines": 9
                    },
                    {
                        "name": "Introspection",
                        "lines": 13
                    },
                    {
                        "name": "Operations on Instance Structures",
                        "lines": 17
                    },
                    {
                        "name": "Inlinable Instance Operations",
                        "lines": 37
                    },
                    {
                        "name": "Introspection",
                        "lines": 6
                    }
                ]
            },
            {
                "name": "AUTHORS",
                "lines": 20,
                "subsections": []
            },
            {
                "name": "COPYRIGHT AND LICENSE",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Class::MOP::Instance - Instance Meta Object\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version 2.2200\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "The Instance Protocol controls the creation of object instances, and the storage of attribute\nvalues in those instances.\n\nUsing this API directly in your own code violates encapsulation, and we recommend that you use\nthe appropriate APIs in Class::MOP::Class and Class::MOP::Attribute instead. Those APIs in turn\ncall the methods in this class as appropriate.\n\nThis class also participates in generating inlined code by providing snippets of code to access\nan object instance.\n",
                "subsections": []
            },
            "METHODS": {
                "content": "",
                "subsections": [
                    {
                        "name": "Object construction",
                        "content": "Class::MOP::Instance->new(%options)\nThis method creates a new meta-instance object.\n\nIt accepts the following keys in %options:\n\n*       associatedmetaclass\n\nThe Class::MOP::Class object for which instances will be created.\n\n*       attributes\n\nAn array reference of Class::MOP::Attribute objects. These are the attributes which\ncan be stored in each instance.\n"
                    },
                    {
                        "name": "Creating and altering instances",
                        "content": "$metainstance->createinstance\nThis method returns a reference blessed into the associated metaclass's class.\n\nThe default is to use a hash reference. Subclasses can override this.\n\n$metainstance->cloneinstance($instance)\nGiven an instance, this method creates a new object by making *shallow* clone of the\noriginal.\n"
                    },
                    {
                        "name": "Introspection",
                        "content": "$metainstance->associatedmetaclass\nThis returns the Class::MOP::Class object associated with the meta-instance object.\n\n$metainstance->getallslots\nThis returns a list of slot names stored in object instances. In almost all cases, slot\nnames correspond directly attribute names.\n\n$metainstance->isvalidslot($slotname)\nThis will return true if $slotname is a valid slot name.\n\n$metainstance->getallattributes\nThis returns a list of attributes corresponding to the attributes passed to the constructor.\n"
                    },
                    {
                        "name": "Operations on Instance Structures",
                        "content": "It's important to understand that the meta-instance object is a different entity from the actual\ninstances it creates. For this reason, any operations on the $instancestructure always require\nthat the object instance be passed to the method.\n\n$metainstance->getslotvalue($instancestructure, $slotname)\n$metainstance->setslotvalue($instancestructure, $slotname, $value)\n$metainstance->initializeslot($instancestructure, $slotname)\n$metainstance->deinitializeslot($instancestructure, $slotname)\n$metainstance->initializeallslots($instancestructure)\n$metainstance->deinitializeallslots($instancestructure)\n$metainstance->isslotinitialized($instancestructure, $slotname)\n$metainstance->weakenslotvalue($instancestructure, $slotname)\n$metainstance->slotvalueisweak($instancestructure, $slotname)\n$metainstance->strengthenslotvalue($instancestructure, $slotname)\n$metainstance->reblessinstancestructure($instancestructure, $newmetaclass)\nThe exact details of what each method does should be fairly obvious from the method name.\n"
                    },
                    {
                        "name": "Inlinable Instance Operations",
                        "content": "$metainstance->isinlinable\nThis is a boolean that indicates whether or not slot access operations can be inlined. By\ndefault it is true, but subclasses can override this.\n\n$metainstance->inlinecreateinstance($classvariable)\nThis method expects a string that, *when inlined*, will become a class name. This would\nliterally be something like '$class', not an actual class name.\n\nIt returns a snippet of code that creates a new object for the class. This is something like\n\" bless {}, $classname \".\n\n$metainstance->inlinegetislvalue\nReturns whether or not \"inlinegetslotvalue\" is a valid lvalue. This can be used to do\nextra optimizations when generating inlined methods.\n\n$metainstance->inlineslotaccess($instancevariable, $slotname)\n$metainstance->inlinegetslotvalue($instancevariable, $slotname)\n$metainstance->inlinesetslotvalue($instancevariable, $slotname, $value)\n$metainstance->inlineinitializeslot($instancevariable, $slotname)\n$metainstance->inlinedeinitializeslot($instancevariable, $slotname)\n$metainstance->inlineisslotinitialized($instancevariable, $slotname)\n$metainstance->inlineweakenslotvalue($instancevariable, $slotname)\n$metainstance->inlinestrengthenslotvalue($instancevariable, $slotname)\nThese methods all expect two arguments. The first is the name of a variable, than when\ninlined, will represent the object instance. Typically this will be a literal string like\n'$[0]'.\n\nThe second argument is a slot name.\n\nThe method returns a snippet of code that, when inlined, performs some operation on the\ninstance.\n\n$metainstance->inlinereblessinstancestructure($instancevariable, $classvariable)\nThis takes the name of a variable that will, when inlined, represent the object instance,\nand the name of a variable that will represent the class to rebless into, and returns code\nto rebless an instance into a class.\n"
                    },
                    {
                        "name": "Introspection",
                        "content": "Class::MOP::Instance->meta\nThis will return a Class::MOP::Class instance for this class.\n\nIt should also be noted that Class::MOP will actually bootstrap this module by installing a\nnumber of attribute meta-objects into its metaclass.\n"
                    }
                ]
            },
            "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": []
            }
        }
    }
}