Moose-2.1005

NAME

Class::MOP::Instance - Instance Meta Object

VERSION

version 2.1005

DESCRIPTION

The Instance Protocol controls the creation of object instances, and the storage of attribute values in those instances.

Using this API directly in your own code violates encapsulation, and we recommend that you use the appropriate APIs in Class::MOP::Class and Class::MOP::Attribute instead. Those APIs in turn call the methods in this class as appropriate.

This class also participates in generating inlined code by providing snippets of code to access an object instance.

Introspection

This returns a list of slot names stored in object instances. In almost all cases, slot names correspond directly attribute names.

$metainstance->is_valid_slot($slot_name)

This will return true if $slot_name is a valid slot name.

$metainstance->get_all_attributes

This returns a list of attributes corresponding to the attributes passed to the constructor.

Operations on Instance Structures

It's important to understand that the meta-instance object is a different entity from the actual instances it creates. For this reason, any operations on the $instance_structure always require that the object instance be passed to the method.

This takes the name of a variable that will, when inlined, represent the object instance, and the name of a variable that will represent the class to rebless into, and returns code to rebless an instance into a class.