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