Class::MOP::Instance - Instance Meta Object
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.
This method creates a new meta-instance object.
It accepts the following keys in
This method returns a reference blessed into the associated metaclass's class.
The default is to use a hash reference. Subclasses can override this.
Given an instance, this method creates a new object by making shallow clone of the original.
This returns the Class::MOP::Class object associated with the meta-instance object.
This returns a list of slot names stored in object instances. In almost all cases, slot names correspond directly attribute names.
This will return true if
$slot_name is a valid slot name.
This returns a list of attributes corresponding to the attributes passed to the constructor.
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.
The exact details of what each method does should be fairly obvious from the method name.
This is a boolean that indicates whether or not slot access operations can be inlined. By default it is true, but subclasses can override this.
This method expects a string that,
will become a class name.
This would literally be something like
not an actual class name.
It returns a snippet of code that creates a new object for the class.
This is something like
Returns whether or not
inline_get_slot_value is a valid lvalue.
This can be used to do extra optimizations when generating inlined methods.
These methods all expect two arguments.
The first is the name of a variable,
than when inlined,
will represent the object instance.
Typically this will be a literal string like
The second argument is a slot name.
The method returns a snippet of code that, when inlined, performs some operation on the instance.
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.
This will return a Class::MOP::Class instance for this class.
It should also be noted that Class::MOP will actually bootstrap this module by installing a number of attribute meta-objects into its metaclass.
Stevan Little <firstname.lastname@example.org>
This software is copyright (c) 2011 by Infinity Interactive, Inc..
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.