Class::MOP::Instance - Instance Meta Object
The meta instance is used by attributes for low level storage.
Using this API generally violates attribute encapsulation and is not reccomended, instead look at "get_value" in Class::MOP::Attribute, "set_value" in Class::MOP::Attribute for the reccomended way to fiddle with attribute values in a generic way, independant of how/whether accessors have been defined. Accessors can be found using "get_attribute" in Class::MOP::Class.
This may seem like over-abstraction, but by abstracting this process into a sub-protocol we make it possible to easily switch the details of how an object's instance is stored with minimal impact. In most cases just subclassing this class will be all you need to do (see the examples; examples/ArrayBasedStorage.pod and examples/InsideOutClass.pod for details).
Creates a new instance meta-object and gathers all the slots from the list of @attrs given.
@attrs
This will return a Class::MOP::Class instance which is related to this class.
This creates the appropriate structure needed for the instance and then calls bless_instance_structure to bless it into the class.
bless_instance_structure
This does just exactly what it says it does.
This too does just exactly what it says it does.
NOTE: There might be more methods added to this part of the API, we will add then when we need them basically.
This returns the metaclass associated with this instance.
This will return the current list of slots based on what was given to this object in new.
new
This will return true if $slot_name is a valid slot name.
$slot_name
An important distinction of this sub-protocol is that the instance meta-object is a different entity from the actual instance it creates. For this reason, any actions on slots require that the $instance_structure is passed into them.
$instance_structure
The names of these methods pretty much explain exactly what they do, if that is not enough then I suggest reading the source, it is very straightfoward.
Each meta-instance should override this method to tell Class::MOP if it's possible to inline the slot access. This is currently only used by Class::MOP::Immutable when performing optimizations.
Yuval Kogman <nothingmuch@woobling.com>
Stevan Little <stevan@iinteractive.com>
Copyright 2006-2008 by Infinity Interactive, Inc.
http://www.iinteractive.com
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Class::MOP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::MOP
CPAN shell
perl -MCPAN -e shell install Class::MOP
For more information on module installation, please visit the detailed CPAN module installation guide.