Need to load the error class or tests fail
[gitmo/Moose.git] / lib / Moose / Cookbook / Meta / Recipe1.pod
CommitLineData
17a65b17 1
2=pod
3
4=head1 NAME
5
6Moose::Cookbook::Meta::Recipe1 - Welcome to the meta world (Why Go Meta?)
7
8=head1 SUMMARY
9
10If you've ever found yourself thinking "Moose is great, but I wish it
11did X differently", then you've gone meta. The meta recipes are all
12about how to change and extend the way Moose does its thing, by
13changing how the various meta classes (C<Moose::Meta::Class>,
14C<Moose::Meta::Attribute>, etc) work.
15
16The metaclass system is a set of classes that describe classes, roles,
17attributes, etc. The metaclass API lets you ask questions about a
18class, like "what attributes does it have?", or "what roles does the
19class do?"
20
21The metaclass system also lets you actively make changes to a class,
22for example by adding new methods.
23
24The interface with which you normally use Moose (C<has>, C<with>,
25C<extends>) is just a thin layer of syntactic sugar over the
26underlying metaclass system.
27
28By extending and changing how this metaclass system works, you can in
29effect create a modified object implementation for your classes.
30
31=head2 Examples
32
33Let's say that you want to additional properties to
34attributes. Specifically, we want to add a "label" property to each
35attribute, so we can write C<<
36My::Class->meta()->get_attribute('size')->label() >>. The first two
37recipes show two different ways to do this, one with a full
38meta-attribute subclass, and the other with an attribute trait.
39
40You might also want to add additional properties to your
41metaclass. For example, if you were writing an ORM based on Moose, you
42could associate a table name with each class via the class's metaclass
43object, letting you write C<< My::Class->meta()->table_name() >>.
44
45=head1 SEE ALSO
46
47Many of the MooseX modules on CPAN implement metaclass extensions. A
48couple good examples include C<MooseX::Singleton> and
49C<MooseX::AttributeHelpers>. For a more complex example see
50C<Fey::ORM>.
51
52=head1 AUTHOR
53
54Dave Rolsky E<lt>autarch@urth.org<gt>
55
56=head1 COPYRIGHT AND LICENSE
57
58Copyright 2008 by Infinity Interactive, Inc.
59
60L<http://www.iinteractive.com>
61
62This library is free software; you can redistribute it and/or modify
63it under the same terms as Perl itself.
64
65=cut
66
67