| Moose documentation | view source | Contained in the Moose distribution. |
ArrayBasedStorage - An example of an Array based instance storage
package Foo;
use metaclass (
':instance_metaclass' => 'ArrayBasedStorage::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
This is a proof of concept using the Instance sub-protocol which uses ARRAY refs to store the instance data.
This is very similar now to the InsideOutClass example, and in fact, they both share the exact same test suite, with the only difference being the Instance metaclass they use.
Stevan Little <stevan@iinteractive.com>
Yuval Kogman <nothingmuch@woobling.com>
Copyright 2006-2008 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Moose documentation | view source | Contained in the Moose distribution. |