8 use Scalar::Util 'blessed';
10 our $VERSION = '0.03';
17 if (!defined($_[0]) || $_[0] =~ /^\:(attribute|method|instance)_metaclass/) {
18 $metaclass = 'Class::MOP::Class';
22 ($metaclass->isa('Class::MOP::Class'))
23 || confess "The metaclass ($metaclass) must be derived from Class::MOP::Class";
26 my $package = caller();
28 # create a meta object so we can install &meta
29 my $meta = $metaclass->initialize($package => %options);
30 $meta->add_method('meta' => sub {
31 # we must re-initialize so that it
32 # works as expected in subclasses,
33 # since metaclass instances are
34 # singletons, this is not really a
36 $metaclass->initialize((blessed($_[0]) || $_[0]) => %options)
48 metaclass - a pragma for installing and using Class::MOP metaclasses
54 # use Class::MOP::Class
57 # ... or use a custom metaclass
58 use metaclass 'MyMetaClass';
60 # ... or use a custom metaclass
61 # and custom attribute and method
63 use metaclass 'MyMetaClass' => (
64 ':attribute_metaclass' => 'MyAttributeMetaClass',
65 ':method_metaclass' => 'MyMethodMetaClass',
68 # ... or just specify custom attribute
69 # and method classes, and Class::MOP::Class
70 # is the assumed metaclass
72 ':attribute_metaclass' => 'MyAttributeMetaClass',
73 ':method_metaclass' => 'MyMethodMetaClass',
78 This is a pragma to make it easier to use a specific metaclass
79 and a set of custom attribute and method metaclasses. It also
80 installs a C<meta> method to your class as well.
84 Stevan Little E<lt>stevan@iinteractive.comE<gt>
86 Yuval Kogman E<lt>nothingmuch@woobling.comE<gt>
88 =head1 COPYRIGHT AND LICENSE
90 Copyright 2006 by Infinity Interactive, Inc.
92 L<http://www.iinteractive.com>
94 This library is free software; you can redistribute it and/or modify
95 it under the same terms as Perl itself.