NAME

InsideOutClass - A set of example metaclasses which implement the Inside-Out technique

SYNOPSIS

package Foo;

use metaclass (
  ':attribute_metaclass' => 'InsideOutClass::Attribute',
  ':instance_metaclass'  => 'InsideOutClass::Instance'
);

__PACKAGE__->meta->add_attribute('foo' => (
    reader => 'get_foo',
    writer => 'set_foo'
));    

sub new  {
    my $class = shift;
    $class->meta->new_object(@_);
} 

# now you can just use the class as normal

DESCRIPTION

This is a set of example metaclasses which implement the Inside-Out class technique. What follows is a brief explaination of the code found in this module.

We must create a subclass of Class::MOP::Instance and override the slot operations. This requires overloading get_slot_value, set_slot_value, slot_initialized, and initialize_slot, as well as their inline counterparts. Additionally we overload add_slot in order to initialize the global hash containing the actual slot values.

And that is pretty much all. Of course I am ignoring need for inside-out objects to be DESTROY-ed, and some other details as well (threading, etc), but this is an example. A real implementation is left as an exercise to the reader.

AUTHORS

Stevan Little <stevan@iinteractive.com>

Yuval Kogman <nothingmuch@woobling.com>

COPYRIGHT AND LICENSE

Copyright 2006, 2007 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.