NAME

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

SYNOPSIS

package Foo;

use metaclass 'Class::MOP::Class' => (
   # tell our metaclass to use the 
   # InsideOut attribute metclass 
   # to construct all it's attributes
  ':attribute_metaclass' => 'InsideOutClass::Attribute'
);

__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::Attribute and override the instance initialization and method generation code. This requires overloading initialize_instance_slot, generate_accessor_method, generate_reader_method, generate_writer_method and generate_predicate_method. All other aspects are taken care of with the existing Class::MOP::Attribute infastructure.

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, but this is an example. A real implementation is left as an exercise to the reader.

AUTHOR

Stevan Little <stevan@iinteractive.com>

COPYRIGHT AND LICENSE

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