0.30
* Class::MOP::Instance
- - added new instance construction protocol
+ - added new instance protocol
- added tests for this
- changed all relevant modules and examples
- Class::MOP::Class
- Class::MOP::Attribute
- examples/*
+ * metaclass
+ - you no longer need to specify the metaclass
+ itself, if it is not there, Class::MOP::Class
+ is just assumed
+ - updated tests for this
+
+ * examples/
+ - added ArrayBasedStorage example to show
+ instance storage using ARRAY refs instead of
+ HASH refs.
+ - added tests for this
+ - InsideOutClass is totally revised using the
+ new instance protocol
+ - added more tests for this
+
0.26 Mon. April 24, 2006
* Class::MOP::Class
- added find_attribute_by_name method
package Foo;
- use metaclass 'Class::MOP::Class' => (
+ use metaclass (
':instance_metaclass' => 'ArrayBasedStorage::Instance'
);
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.
+
=head1 AUTHOR
Stevan Little E<lt>stevan@iinteractive.comE<gt>
package Foo;
- use metaclass 'Class::MOP::Class' => (
+ use metaclass (
':instance_metaclass' => 'InsideOutClass::Instance'
);
package BinaryTree;
- use metaclass 'Class::MOP::Class' => (
- ':attribute_metaclass' => 'LazyClass::Attribute'
+ use metaclass (
+ ':attribute_metaclass' => 'LazyClass::Attribute',
+ ':instance_metaclass' => 'LazyClass::Instance',
);
BinaryTree->meta->add_attribute('$:node' => (
use strict;
use warnings;
- use metaclass 'Class::MOP::Class' => (
+ use metaclass (
':instance_metaclass' => 'ArrayBasedStorage::Instance',
);
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 (occasionally it
-requires that you also subclass Class::MOP::Attribute if
-you require some kind of specific attribute initializations).
+this class will be all you need to do (see the examples;
+F<examples/ArrayBasedStorage.pod> and
+F<examples/InsideOutClass.pod> for details).
=head1 METHODS
use Carp 'confess';
use Scalar::Util 'blessed';
-our $VERSION = '0.02';
+our $VERSION = '0.03';
use Class::MOP;
sub import {
shift;
- my $metaclass = shift || 'Class::MOP::Class';
+ my $metaclass;
+ if (!defined($_[0]) || $_[0] =~ /^\:(attribute|method|instance)_metaclass/) {
+ $metaclass = 'Class::MOP::Class';
+ }
+ else {
+ $metaclass = shift;
+ ($metaclass->isa('Class::MOP::Class'))
+ || confess 'The metaclass must be derived from Class::MOP::Class';
+ }
my %options = @_;
my $package = caller();
- ($metaclass->isa('Class::MOP::Class'))
- || confess 'The metaclass must be derived from Class::MOP::Class';
-
# create a meta object so we can install &meta
my $meta = $metaclass->initialize($package => %options);
$meta->add_method('meta' => sub {
':method_metaclass' => 'MyMethodMetaClass',
);
+ # ... or just specify custom attribute
+ # and method classes, and Class::MOP::Class
+ # is the assumed metaclass
+ use metaclass (
+ ':attribute_metaclass' => 'MyAttributeMetaClass',
+ ':method_metaclass' => 'MyMethodMetaClass',
+ );
+
=head1 DESCRIPTION
This is a pragma to make it easier to use a specific metaclass
use strict;
use warnings;
- use metaclass 'Class::MOP::Class' => (
+ use metaclass (
':instance_metaclass' => 'InsideOutClass::Instance'
);
use strict;
use warnings;
- use metaclass 'Class::MOP::Class' => (
+ use metaclass (
':instance_metaclass' => 'InsideOutClass::Instance'
);
{
package BinaryTree;
- use metaclass 'Class::MOP::Class' => (
+ use metaclass (
':attribute_metaclass' => 'LazyClass::Attribute',
':instance_metaclass' => 'LazyClass::Instance',
);
use strict;
use warnings;
- use metaclass 'Class::MOP::Class' => (
+ use metaclass (
':instance_metaclass' => 'ArrayBasedStorage::Instance',
);
use strict;
use warnings;
- use metaclass 'Class::MOP::Class' => (
+ use metaclass (
':instance_metaclass' => 'ArrayBasedStorage::Instance',
);